Closed siemenvdn closed 3 months ago
I've created a PR for the desired changes. I'll take the responsibility to include the new commands in the project-template, and notify circle-node of these changes.
No I'd avoid y'all writing devops stuff in all your package.json. It is EXTREMELY limiting to us if we need to change it because we're changing actions, splitting stuff up, optimising stuff, etc…
Honestly I'm more interested in moving some current/existing pnpm lint
and pnpm build
to their actual node commands, so we can optimize them as needed.
That wouldn't be ideal, our framework already handles alot of setup/teardown, but it doesnt provide a functionality to run a single file before all tests are executed.
The problem is that they're sharing a Typesense instance, if we'd include that setup in our test setup they'd all try to initialise the same instance at the same time. Which results in alot of errors.
If it would be included in a new step it would also be sufficient. There is no way to handle this on our end except running a setup script/command.
I suggest leaving things as be.
But, since tests suites run in parallel, which means any test suite can be the first. There needs to be a global setup hook for db migrations and other things that need to be run before the tests.
What do you suggest? @djbe
Like I said, tell us which script we should execute before actually running the tests, to set-up the services. We can check if the path exists, so it doesn't fail on older projects.
@djbe The global-setup file will be placed at path dist/src/utils/test-setup/global-setup.js
.
@siemenvdn added a check to see if the file exists, and then runs it: https://github.com/wisemen-digital/devops-github-actions/blob/main/.github/workflows/node-build-and-test.yml#L193-L195
Refs: ENG-1724
For NestJS projects, we need to pre-run a single setup file before all tests start. We included this in the
pnpm test
command. So if the current tests are ran withnode --test
, those files won't be executed. Which results in all failing tests. We could provide apnpm test:pipeline
command where we'll add the--test-reporter=tap --test-reporter-destination=stdout --test-reporter=junit --test-reporter-destination=\"test-report-junit.xml\"
since we like to use thespec
test-reporter locally.Then the
cp -f '.env.test' '.env'
command could also be forgotten about, since we already specify that the node-tests should use the.env.test