-
Notifications
You must be signed in to change notification settings - Fork 409
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
Express ESM versioned tests #1349
Conversation
// TODO: remove this when we decide on how to address | ||
// here: https://issues.newrelic.com/browse/NEWRELIC-3321 | ||
'node/no-unsupported-features/es-syntax': 'off', | ||
'node/no-unpublished-import': 'off', |
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.
I will open PR to put this in the shared eslint ruleset. we already do it for the cjs equivalents: https://github.com/newrelic/eslint-config-newrelic/blob/main/index.js#L108
…lso refactored relying on import + assert type as it is not yet supported in eslint parsing. lastly, renamed test .mjs so eslint can be consistent from root of agent and in test/versioned/express-esm folder
package.json to include the 2 suites we will run. finished porting segments tests, abstracted reusable express helpers
…eatures/es-syntax rule
021cb9f
to
3a91273
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.
Just have one question about the test package.json, otherwise looks good!
Proposed Release Notes
Links
Closes https://issues.newrelic.com/browse/NEWRELIC-3119
Details
This will fail until we land the test utils pr and publish a new version. In the meantime you can test this locally by checking out the branch in the test utils PR, running npm link in this branch and then just run
npm run versioned:major
. You will see theexpress-esm
tests pass. It's also worth noting ESM flavored versioned tests will have some limitations. Since the loader only loads at the start of a test file, we cannot setup and teardown a mocked agent in a before/afterEach hook. Going forward if we add more exclusive ESM versioned tests, the test will need to be made atomic to avoid cross-fire between tests. The most notable changes in this PR are:transactionFinished
handler and removing after each test. This was the biggest downside of not being able to bootstrap and teardown a new agent between every test.When we originally scoped these port versioned tests to ESM we thought it'd be as easy as swap a few require statements for import and call it a day but it turned out to be a large effort. That's why I did not port every single test from the cjs express tests. Verifying both transaction and segment naming tests work is a good compromise and gives me enough confidence that the agent ESM loader is properly tested via integration tests.