-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: drop support for jest<27.2.5 #3392
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const semver = require('semver'); | ||
|
||
const detoxPackageJson = require('../../../package.json'); | ||
const DetoxRuntimeError = require('../../../src/errors/DetoxRuntimeError'); | ||
|
||
function assertJestCircus27(maybeProjectConfig) { | ||
const projectConfig = maybeProjectConfig.projectConfig || maybeProjectConfig; | ||
|
||
if (!/jest-circus/.test(projectConfig.testRunner)) { | ||
throw new DetoxRuntimeError({ | ||
message: 'Cannot continue without Jest Circus test runner underneath, exiting.', | ||
hint: 'Make sure that in your Jest config you have no "testRunner" property or it is explicitly set to "jest-circus/runner".', | ||
debugInfo: `The test runner powering your configuration is:\n${projectConfig.testRunner}`, | ||
}); | ||
} | ||
|
||
const circusPackageJson = path.join(path.dirname(projectConfig.testRunner), 'package.json'); | ||
if (!fs.existsSync(circusPackageJson)) { | ||
throw new DetoxRuntimeError({ | ||
message: 'Check that you have an installed copy of "jest-circus" npm package, exiting.', | ||
debugInfo: `Its package.json file is missing: ${circusPackageJson}`, | ||
}); | ||
} | ||
|
||
const circusVersion = require(circusPackageJson).version; | ||
if (!circusVersion) { | ||
throw new DetoxRuntimeError({ | ||
message: 'Check that you have an valid copy of "jest-circus" npm package, exiting.', | ||
debugInfo: `Its package.json file has no "version" property. See:\n` + circusPackageJson, | ||
}); | ||
} | ||
|
||
assertSupportedVersion(circusVersion); | ||
|
||
return maybeProjectConfig; | ||
} | ||
|
||
function assertSupportedVersion(actualVersion) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On a nit-picky note related strictly to styling: Why have a specific function just for that last part (version assertion), and not for any of the preliminary assertions as well? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, it could have looked a bit better! 👍 |
||
const supportedRange = detoxPackageJson.peerDependencies.jest; | ||
const minSupportedVersion = semver.minVersion(supportedRange); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great |
||
|
||
if (semver.lt(actualVersion, minSupportedVersion)) { | ||
throw new DetoxRuntimeError({ | ||
message: `Detected an unsupported jest@${actualVersion} version.`, | ||
hint: `Please upgrade your Jest test runner to the supported range: ${supportedRange}.` | ||
}); | ||
} | ||
} | ||
|
||
module.exports = { | ||
assertJestCircus27, | ||
assertSupportedVersion, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { assertSupportedVersion } = require('./assertJestCircus27'); | ||
|
||
describe('assertSupportedVersion', () => { | ||
test.each([ | ||
['27.2.5'], | ||
['27.2.6-prerelease.0'], | ||
['27.3.0'], | ||
['28.0.0-alpha.1'], | ||
['28.0.0'], | ||
['28.1.0'], | ||
['29.0.0-next.0'], | ||
['30.0.0'], | ||
])('should pass for %j', (version) => { | ||
expect(() => assertSupportedVersion(version)).not.toThrow(); | ||
}); | ||
|
||
test.each([ | ||
['26.0.0'], | ||
['27.2.4'], | ||
])('should throw an error for %j', (version) => { | ||
expect(() => assertSupportedVersion(version)).toThrowError(/unsupported jest.*version/); | ||
}); | ||
}); |
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.
OK, I looked into jest's new VerboseReporter and it seems like it is indeed now equivalent to DetoxStreamlineJestReporter ✅
+2 points to for being great visionaries