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
Migrate unit tests to Mocha #5600
Conversation
I love the way the tests look, thanks for taking this on Jack! I can't wait to drop the custom test runner code. To answer your question, I'd prefer a single large PR in this case since the changes are mostly mechanical. |
d58ef39
to
f465e2e
Compare
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.
Rubberstamp LGTM as discussed offline
Rather than maintain our own test runner we should instead lean on the community and use Mocha which is very popular and also our test runner of choice in DevTools too. Note that this commit doesn't remove the TestRunner source as it's still used for other unit tests, but they will be updated in a future PR and then we can remove the TestRunner. The main bulk of this PR is updating the tests as the old TestRunner passed in contextual data via the `it` function callback whereas Mocha does not, so we introduce some helpers for the tests to make it easier.
Our custom TestRunner used to look for these but now we aren't using it let's enforce it using ESLint.
4c1d055
to
d602cd9
Compare
Not all tests need a global browser + page, so we have helpers that can be imported on a per-test basis.
a6f3a67
to
0d14c1a
Compare
const GOLDEN_DIR = path.join(__dirname, 'golden-' + suffix); | ||
const OUTPUT_DIR = path.join(__dirname, 'output-' + suffix); | ||
if (fs.existsSync(OUTPUT_DIR)) | ||
rm(OUTPUT_DIR); |
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.
Just hit this: rm()
is undefined here.
@mathiasbynens this is a proof of concept of how we can move to Mocha by replacing the custom test runner with a few small helpers.
I have migrated cookies.spec.js and all the tests pass.
I'm keen to plough ahead and start migrating more test files, but wanted to raise this PR to check:
cookies.mocha.spec.js
renaming we can run one test at a time rather than migrate in bulk. Would you rather one PR for one test file or I just do them all in bulk? The changes are mechanical mostly so I think one PR might be OK.