Update “x-test” / “x-test-cli”.#369
Conversation
| // Set a high bar for code coverage! | ||
| coverage(new URL('../x-element.js', import.meta.url).href, 100); | ||
| coverage(new URL('../x-parser.js', import.meta.url).href, 100); | ||
| coverage(new URL('../x-template.js', import.meta.url).href, 100); |
There was a problem hiding this comment.
☝️ — All coverage stuff is moved to the CLI.
| @@ -1,32 +1,22 @@ | |||
| import { test, coverage } from '@netflix/x-test/x-test.js'; | |||
| import { load } from '@netflix/x-test/x-test.js'; | |||
There was a problem hiding this comment.
Top-level test renamed to load.
| @@ -1,4 +1,4 @@ | |||
| import { assert, describe, it } from '@netflix/x-test/x-test.js'; | |||
| import { assert, suite, test } from '@netflix/x-test/x-test.js'; | |||
There was a problem hiding this comment.
Top-level describe renamed to suite and top-level it renamed to test (matches classic unit testing / TAP-y language).
| 'initialized as expected' | ||
| ); | ||
|
|
||
| assert.deepEqual(el.changes, [ |
There was a problem hiding this comment.
Drafting off node:assert/strict — x-test now has assert.deepEqual baked in. Currently, it is only assert / assert.deepEqual (until there is actual need for more).
| const expectedTokens = []; | ||
| const tokens = html``; | ||
| assert(deepEqual(tokens, expectedTokens), stringifyTokens(tokens)); | ||
| assert.deepEqual([...tokens], expectedTokens, stringifyTokens(tokens)); |
There was a problem hiding this comment.
Look at that! Moving to a proper deepEqual implementation actually forced us to fix our tests. We were accidentally failing to acknowledge that there were symbol keys on this tokens object. Now, you have to deal with it in the actual test block. This passed before because we happened to not check non-enumerable keys in our lazy deepEqual implementation. I like that it forces us to [...]-spread here since it keys you into additional context.
| "node": ">=8" | ||
| } | ||
| }, | ||
| "node_modules/tap-parser": { |
There was a problem hiding this comment.
Underlying x-test-cli internalized its TAP interpreter. That means we got to drop a few dev lines from our package-lock.json file as well ❤️
|
@klebba — No rush on this, just plumbing through changes to get some more feedback on the |
Adopts the latest interface changes which align more-closely to Node’s `node --test`, `node:test`, and `node:assert` standards. Some notes: - Coverage moved to the CLI library, see `x-test.config.js`. - Conventional `./coverage/lcov.info` files get generated when you test. - Failures get re-iterated in output (for easy AI `tail`-ing). - Output TAP stream is stylized in supported terminals / environments. - Top-level interface is `load`, `suite`, `test`, and `assert` now.
2d05550 to
830fba2
Compare
| client: 'puppeteer', | ||
| browser: 'chromium', | ||
| coverage: true, | ||
| coverageGoals: { |
There was a problem hiding this comment.
Here’s where we configure coverage goals.
| const expectedMessage = '[#155]'; | ||
| assertThrows(callback, expectedMessage, { startsWith: true }); | ||
| const expectedMessage = 'Error: [#155]'; | ||
| assert.throws(callback, new RegExp('^' + RegExp.escape(expectedMessage))); |
There was a problem hiding this comment.
The assert.throws is also just available from x-test now. Again, this is copying the interface of node:assert. We could expand this to support more than just the pattern in the future. Honestly, with the addition of RegExp.escape — it’s not too bad to reliably convert a string to a pattern like this.
Adopts the latest interface changes which align more-closely to Node’s
node --test,node:test, andnode:assertstandards.Some notes:
x-test.config.js../coverage/lcov.infofiles get generated when you test.tail-ing).load,suite,test, andassertnow.