-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
test(NODE-3817): refactor RunOn filter in legacy spec runner to use mocha hooks #3119
Conversation
80ffc07
to
516c303
Compare
test/integration/retryable-writes/retryable_writes.spec.test.js
Outdated
Show resolved
Hide resolved
const { inspect } = require('util'); | ||
|
||
const IS_UNIT = process.argv.length >= 3 && process.argv[2].includes('unit'); |
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.
Maybe we could create an environment variable and feed it into the tests, like IS_UNIT=true
, instead of relying on parsing the test directory structure?
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.
This is something we'll want everyone's eyes on, I'm cool with that approach, maybe more clarity like NO_SERVER=true
. But also folks shouldn't have to do this locally so maybe there's some heuristic we can figure out here.
- In the case of no server running:
- I want to be able to run
mocha test/unit
without issue so this before hook has to return early. - I expect
mocha test/integration
to fail server selection - I expect
mocha test/unit test/integration
to either fail server selection, or crash tests that accessthis.configuration.x
, since it will be undefined
- I want to be able to run
- In the case of a server running:
- I want to be able to run
mocha test/unit test/integration
without issue. <- currently this would fail, cus my logic makes the hook return early, leaving configuration undefined - I want to run
mocha test/unit
without issue, in this case it will still connect to the server and define this.configuration it's just that the unit tests don't use it, extra work but no biggie - ofc int tests work as expected
- I want to be able to run
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.
@dariakp @durran, now that this is in team review could use a meeting of minds here for best approach.
I haven't added an env var like bailey asked yet, that could be done in CI for our lint task, but I wouldn't want to folks to have to do that locally necessarily to run unit tests without a server up, but then again it isn't a huge hurdle.
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.
can we instead set up a different mocharc file for the integration directory vs the unit directory?
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.
Went with the bespoke config option for int tests.
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.
Capturing some feedback that I started in a separate tab
test/integration/server-discovery-and-monitoring/server_discovery_and_monitoring.spec.test.js
Outdated
Show resolved
Hide resolved
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.
LGTM :)
bbb5e0c
to
511fa8a
Compare
513dc1b
to
6dc8239
Compare
Description
What is changing?
topologySatisfies
can be called from a test or beforeEach hook--file
flag is slated for removal)Is the unit test detection logic strong enough? it uses theprocess.argv[2]
string.mocharc.json
fileWhat is the motivation for this change?
This makes our test run more clear since there is not longer duplicates of a test. For example a countDocuments spec test is the same regardless of what topology it is running against, so we shouldn't duplicate the test name and function based on all possible topology we'd want to run that test against.
Migrating our hooks to the require format is to help us keep up to date on mocha's expectations. Writing them in this format is a precurser to potentially running tests in parallel.
Double check the following
npm run check:lint
script<type>(NODE-xxxx)<!>: <description>