2

I'm running tests with the gcloud datastore emulator for node.
I want to reset the db before each test.

Is there a quick way like a 'drop' command or something I can use in a beforeEach block ?

Gyro
  • 944
  • 1
  • 8
  • 16

2 Answers2

1

Just simply remove the db file. Usually, it is ~/.config/gcloud/emulators/datastore/WEB-INF/appengine-generated/local_db.bin.

Hung Hoang
  • 697
  • 5
  • 14
  • How can I do that in a beforeEach block with mocha ? I'm not sure that will work while the emulator is already up. It expects some file to exist during session. – Gyro Aug 20 '16 at 08:56
  • Just delete the file, you can use `del` or `rimraf` for that. Tested it, I can delete `local_db.bin` while emulator is running, and it works fine. – Hung Hoang Aug 23 '16 at 02:53
  • ok thanks ! Since I want to do it in a beforeEach block, I used node fs module – Gyro Aug 24 '16 at 09:47
1

You could also send a POST /reset request to the emulator, mentioned here.

Renato Back
  • 706
  • 1
  • 10
  • 21