Refactor: move migration script test out of linter#9230
Refactor: move migration script test out of linter#9230queengooborg merged 3 commits intomdn:mainfrom bershanskiy:linter-refactor-testMigrations
Conversation
|
(Force-pushed after rebase.) |
|
Just to clarify: this PR is OK as is, but I marked it as "Draft" because it is bound to merge conflict with #9229. |
|
(Force-pushed after rebase.) |
|
I think this will no longer have merge conflicts with #9229, so marking this as ready. |
queengooborg
left a comment
There was a problem hiding this comment.
I'm definitely down for script tests being moved out of lint.js -- thank you! Just got a little nit, but LGTM overall:
|
|
||
| if (output !== expected) { | ||
| logger.error(chalk`{red WebView flags aren't removed properly!} | ||
| if (output !== expected) { |
There was a problem hiding this comment.
Could we opt for using assert.deepStrictEqual(output, expected) here?
There was a problem hiding this comment.
If we elect to use assert.deepStrictEqual(output, expected) we can probably remove the whole JSON normalization (parsing and then stringification of data). Should I do that?
There was a problem hiding this comment.
Yeah, that's actually a great point, we could simply write this as:
for (const test of tests) {
assert.deepStrictEqual(output, expected);
}There was a problem hiding this comment.
I used the following:
for (const test of tests) {
const expected = test.output;
const output = JSON.parse(JSON.stringify(test.input), removeWebViewFlags);
assert.deepStrictEqual(output, expected);
}
|
Looks like your other PR conflicted with this one, so this PR needs a quick rebase! |
This PR is very similar to #9229, but it refactors a different function,
testMigrations().This PR moves a unit test out of linter and into a separate mocha test file similar to
utils.test.js. This unit test is still called bynpm run test, sincetestscript includesnpm run mocha.For reviewer convenience, I split it up into two commits: the actual change is in the first commit and the second commit is just
npm run fix.Running
npm run testBefore:
After:
A checklist to help your pull request get merged faster: