How to reset emulator DB before each test?
Asked Answered
L

2

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 ?

Lucretialucretius answered 18/8, 2016 at 21:41 Comment(0)
Y
1

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

Yemane answered 19/8, 2016 at 4:8 Comment(3)
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.Lucretialucretius
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.Yemane
ok thanks ! Since I want to do it in a beforeEach block, I used node fs moduleLucretialucretius
C
1

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

Carolincarolina answered 3/7, 2020 at 15:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.