Skip to content

chore(tests): run unit tests, update script#1365

Merged
LeoMcA merged 17 commits intomainfrom
run-unit-tests
Mar 26, 2026
Merged

chore(tests): run unit tests, update script#1365
LeoMcA merged 17 commits intomainfrom
run-unit-tests

Conversation

@LeoMcA
Copy link
Copy Markdown
Member

@LeoMcA LeoMcA commented Mar 12, 2026

Would recommend reviewing commit-by-commit with whitespace changes disabled.

Adds unit tests to our scripts/tests.js file, and revamps that file a little bit to support that. Reduces the number of scripts in package.json (I don't like it when they get out of hand and overly confusing!)

This introduces a single npm test entrypoint which can be used for running:

  • linters
  • unit tests
  • e2e tests against:
    • currently fred or rari servers
    • a fred dev server
    • a fred preview server
    • fred/rari servers within a content repo

@LeoMcA LeoMcA requested review from a team and mdn-bot as code owners March 12, 2026 12:43
@LeoMcA LeoMcA requested a review from caugner March 12, 2026 12:43
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 12, 2026

75394a8 was deployed to: https://fred-pr1365.review.mdn.allizom.net/

@LeoMcA LeoMcA marked this pull request as draft March 12, 2026 12:49
@LeoMcA LeoMcA marked this pull request as ready for review March 12, 2026 13:28
Comment thread .github/workflows/npm-publish-simulation.yml Outdated
Comment thread scripts/tests.js Outdated
Comment thread scripts/tests.js
try {
await Promise.all(runs);
} catch {
process.exitCode = 1;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Don't the individual commands return codes other than 1?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it matters, if any of them return a failing exit code, concurrently will throw a error, and we then make the overall script return a failing exit code in order to fail CI etc.

Comment thread scripts/tests.js Outdated
Comment thread scripts/tests.js Outdated
Comment thread .github/workflows/npm-publish-simulation.yml Outdated
Comment thread package.json
"ssr": "node build/ssr.js",
"lit-analyzer": "npx @jackolope/lit-analyzer --rules.no-incompatible-type-binding off",
"test": "lefthook run --force pre-push",
"test": "node scripts/tests.js",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] Do we need to update the pre-push hook?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it depends, do we want to run unit tests automatically on pre-push? Perhaps we should also let the tests.js script own the linters we run, rather than delegating that to the lefthook config file? I've leave this for a later PR.

Comment thread .github/workflows/test.yml Outdated
@LeoMcA LeoMcA merged commit 058621a into main Mar 26, 2026
13 checks passed
@LeoMcA LeoMcA deleted the run-unit-tests branch March 26, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants