-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: reseed db before tests #7747
feat: reseed db before tests #7747
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replicating this locally, I get "message": "Table 'etherealengine.analytics' doesn't exist",
My guess is this doesn't work for multiple tests.
@@ -33,7 +33,9 @@ export default (app: Application): void => { | |||
promiseReject = reject | |||
}) | |||
|
|||
app.setup = async function (...args: any) { | |||
app.setup = async function (...args) { | |||
const testModeForceRefresh = app.get('testModeForceRefresh') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than setting this manually, we can rely on appConfig.testEnabled
, such that it is automatically applied every time createFeathersExpressApp
is run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to do this initially but encountered some problems. DB is also reseeded before tests (in npm run pretest
) which requires process.exit(0)
here. Using appConfig.testEnabled
will have some problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh I see. Let's use the appConfig instead of feathers internal state. We can add a new configuration option with the desired functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this change!
@HexaField Can you please tell me the steps you followed to replicate this? This is because I am testing this on a fresh database and not getting any error. Can you please recheck it once? |
@aditya-mitra if (appConfig.testEnabled)
app.set('testModeForceRefresh', true) to This is the result:
|
@HexaField I found the error (it was a problem with a test) and have fixed it.
I have also added the setting to reseed db in |
Fantastic, let's replace the usage of |
Done with these changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in server start.ts
L27 and server-core seeder.tsx
L63 we should add && !config.testEnabled
to both conditionals
Thank you for your pull request and welcome to the Ethereal Engine developer community! We require contributors to sign our Copyright Assignment Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign the agreement at https://forms.gle/15ENsSAJGKf2ozvB7 The agreement has not been signed by users: @aditya-mitra. After signing the agreement, you can ask me to recheck this PR by posting |
@cla-bot check |
Checking that all contributors to this PR are verified. |
Summary
Using an app setting
testModeForceRefresh = true
, the database can be seed in between tests.Here, this setting has been used in user.test.ts
References
Closes #7726
Checklist
QA Steps
List any additional steps required to QA the changes of this PR, as well as any supplemental images or videos.