-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING: please migrate your projects to Jest 28.x or 27.x
- Loading branch information
Showing
12 changed files
with
96 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 0 additions & 97 deletions
97
detox/runners/jest-circus/reporters/DetoxStreamlineJestReporter.js
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
const supportedRange = detoxPackageJson.peerDependencies.jest; | ||
const minSupportedVersion = semver.minVersion(supportedRange); | ||
|
||
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, | ||
}; |
23 changes: 23 additions & 0 deletions
23
detox/runners/jest-circus/utils/assertJestCircus27.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters