-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Upgrade to babel@7 #1043
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
Merged
Merged
Upgrade to babel@7 #1043
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
88a8324
Upgrade to babel@7
Andarist 25679b6
Run tests for all versions of React in a single jest process
Andarist a8689be
Add tests against react@16.5
Andarist cdbc49e
Simplify test script
Andarist 83861cb
Remove unused getTestDeps.js files & adjusted CONTRIBUTING.md info
Andarist 65af5d9
Create test directories if they are missing
Andarist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Run tests for all versions of React in a single jest process
- Loading branch information
commit 25679b66eee80b0920d3eeb5ca71b233476ca2d8
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
---|---|---|
@@ -1,17 +1,34 @@ | ||
const { readdirSync } = require('fs') | ||
const { join } = require('path') | ||
const npmRun = require('npm-run') | ||
const version = process.env.REACT || '16.4' | ||
const LATEST_VERSION = '16.4' | ||
const version = process.env.REACT || LATEST_VERSION | ||
|
||
try { | ||
require('./install-test-deps.js') | ||
if (version.toLowerCase() === 'all') { | ||
readdirSync(join(__dirname, 'react')).forEach(version => { | ||
npmRun.execSync(`cd test/react/${version} && npm test -- -c ../../jest.config.js`, { stdio: 'inherit' }) | ||
}) | ||
} else { | ||
npmRun.execSync(`cd test/react/${version} && npm test -- -c ../../jest.config.js`, { stdio: 'inherit' }) | ||
const jestConfig = { | ||
testURL: 'http://localhost', | ||
collectCoverage: true, | ||
coverageDirectory: `${__dirname}/coverage`, | ||
transform: { | ||
'.js$': `${__dirname}/babel-transformer.jest.js`, | ||
}, | ||
} | ||
|
||
require('./install-test-deps.js') | ||
|
||
if (version.toLowerCase() === 'all') { | ||
const allVersionsConfig = { | ||
...jestConfig, | ||
rootDir: __dirname, | ||
// every directory has the same coverage, so we collect it only from one | ||
collectCoverageFrom: [`react/${LATEST_VERSION}/src/**.js`] | ||
} | ||
npmRun.execSync(`node ./node_modules/.bin/jest -c '${JSON.stringify(allVersionsConfig)}'`, { stdio: 'inherit' }) | ||
} else { | ||
try { | ||
const specificVersionConfig = { | ||
...jestConfig, | ||
rootDir: `${__dirname}/react/${version}`, | ||
} | ||
npmRun.execSync(`cd test/react/${version} && npm test -- -c '${JSON.stringify(specificVersionConfig)}'`, { stdio: 'inherit' }) | ||
} finally { | ||
npmRun.execSync('cd ../../..') | ||
} | ||
} finally { | ||
npmRun.execSync('cd ../../..') | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
it seems to me that
node ./node_modules/.bin/jest
can be used when testing a specific version too, combining this withrootDir
option would allow us to remove usage ofnpm-run
here, removingcd
dance & removing 'artificial' test scripts from nested package.jsonsWDYT?
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.
First, if we're using npm-run, then this should just be
jest -c ...
. That module automatically adds the .bin dir to the PATH.We could actually make use of
jest --projects
in this case. That might be easier, as each version of React would be testable in isolation and without as much tooling.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.
Cool, didnt know that - gonna chang it in a minute.
I thought about it, but I think that would require keeping a copy of the jest config per each react version and is IMHO annoying in a long run (when it needs updating).
Also I wasnt sure how to collect coverage in
--projects
case as we wont to collect it only from a single project.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.
Damn, it doesn't do per-project coverage? That seems like an oversight.
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 guess it might have, we just have exactly the same coverage here per project as noticed by @cellog. I guess overcollecting the coverage doesnt do us harm, but im not sure how CI takes the coverage for its report. Is the path configurable? Gonna look into that later as im on the mobile right now. If its configurable then i guess we might just point to the latest react directory and be done with it (leting jest collect in each directory).
There is still an issue of having to duplicate jest config all over the place though (if u want to use the projects feature)