-
Notifications
You must be signed in to change notification settings - Fork 915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backend] extend our vitest config for easier dev process #5796
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5796 +/- ##
==========================================
- Coverage 66.68% 66.68% -0.01%
==========================================
Files 540 540
Lines 64349 64349
Branches 5251 5251
==========================================
- Hits 42912 42909 -3
- Misses 21437 21440 +3 ☔ View full report in Codecov by Sentry. |
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.
Thanks for making tests easier :)
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.
Could you move globalSetup to ts or is it too complex ?
And maybe also tests/02-integration/00-inject/loader-test.js file.
If you have time, this comment is not a blocker at all.
3972324
to
3d01224
Compare
6f29a12
to
ebfecd0
Compare
5884121
to
cde7fe5
Compare
89f9acc
to
e958bf6
Compare
6b3ba73
to
8d8d2bd
Compare
e4dd87f
to
cdad59d
Compare
@@ -19,7 +19,11 @@ | |||
"start-cluster": "NODE_ENV=cluster node build/back.js", | |||
"serv": "node build/back.js", | |||
"insert:dev": "node build/script-insert-dataset.js", | |||
"test:dev": "vitest watch --config vitest.config.dev.ts", | |||
"test:dev:init": "INIT_TEST_PLATFORM=true vitest run --config vitest.config.dev.ts --testNamePattern=\"Should import creation succeed\" tests/02-integration/00-inject/loader-test.ts", |
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.
This step is not working on my computer, "test:dev:init" is not working on my computer, I have a error at "Should import creation succeed" step,
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 suppose you do not have more details ?
Are you sure it's not related to a python client version mismatch on your local setup?
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 just managed to run this step without any issue
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.
ok testing again now
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.
As a side note, it might be a good time to improve the developper documentation as follow up PR https://docs.opencti.io/latest/development/platform/#for-testing
655453f
to
d793a45
Compare
Improved our tooling to be able to run dev tests locally quickly.
the
globalSetup
for vitest has been refactored and can be piloted by 2 env variables,INIT_TEST_PLATFORM
andSKIP_CLEANUP_PLATFORM
. We make use of these variables in new yarn scripts:yarn test:dev:init
to cleanup your test DB, start a platform, run the loader tests that populates the database. This command won't run any other test.yarn test:dev:resume <name-of-a-test-file.js>
to run the specified test file only, the DB won't be cleaned up after runyarn test:watch:resume <name-of-a-test-file.js>
to run in watch modeThis makes developing integration tests much quicker and without having to tweak some config files locally.
As for unit tests, I would still advise to use the vitest integration in the IDE. Nothing beats that as it just won't start a platform, useless for unit tests.
The previous commands still exists ;
yarn test:dev
for 1 complete run (cleanup/setup/all tests suites)yarn test:watch
for a complete execution in watch modeyarn test
unchanged, used by CI to run once in silent with coverage