Skip to content

Update “x-test” / “x-test-cli”.#369

Open
theengineear wants to merge 1 commit intomainfrom
update-x-test
Open

Update “x-test” / “x-test-cli”.#369
theengineear wants to merge 1 commit intomainfrom
update-x-test

Conversation

@theengineear
Copy link
Copy Markdown
Collaborator

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.
Screenshot 2026-04-24 at 2 43 25 PM

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.
Comment thread test/index.js
// 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);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

☝️ — All coverage stuff is moved to the CLI.

Comment thread test/index.js
@@ -1,32 +1,22 @@
import { test, coverage } from '@netflix/x-test/x-test.js';
import { load } from '@netflix/x-test/x-test.js';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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';
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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, [
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Drafting off node:assert/strictx-test now has assert.deepEqual baked in. Currently, it is only assert / assert.deepEqual (until there is actual need for more).

Comment thread test/test-parser.js
const expectedTokens = [];
const tokens = html``;
assert(deepEqual(tokens, expectedTokens), stringifyTokens(tokens));
assert.deepEqual([...tokens], expectedTokens, stringifyTokens(tokens));
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread x-test.config.js
client: 'puppeteer',
browser: 'chromium',
coverage: true,
coverageTargets: {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Here’s where we configure coverage goals.

Comment thread package-lock.json
"node": ">=8"
}
},
"node_modules/tap-parser": {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 ❤️

@theengineear
Copy link
Copy Markdown
Collaborator Author

@klebba — No rush on this, just plumbing through changes to get some more feedback on the x-test changes. I left commentary on the PR and I think the screen grab in the description is a good summary of what’s new.

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.

1 participant