Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"pretest": "npm run flow && eslint src test",
"test": "jest",
"tdd": "jest --watch",
"flow": "flow"
"flow": "flow",
"test:react-dom":
"jest --config ./scripts/jest/config.react-dom-test-suite.js"
},
"lint-staged": {
"src/**/*.{js}": ["eslint"],
Expand Down
12 changes: 12 additions & 0 deletions scripts/clone-react-dom-test-suite/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { clone } = require('./utils');

const repoURL = 'git@github.com:facebook/react.git';
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd clone based on tag as well maybe. I don't know that we want to be testing against a master all the time, better to test against the tests for a specific version e.g. 16.2.0

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried it'll slow down the cloning. Just clarifying, whats does the workflow look like again. How often will we be running this script?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd think wed only run it in CI or as one offs probably. I don't think cloning by tag would affect the speed tho (could be wrong tho)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clone just the latest tag?

const clonePath = './test/react-test-suite';
console.log('Cloning...');
clone(repoURL, clonePath)
.then(() => {
console.log('cloned');
})
.catch(e => {
console.log('Cloning failed');
});
18 changes: 18 additions & 0 deletions scripts/clone-react-dom-test-suite/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { exec } = require('child_process');
const { transform } = require('babel-core');

module.exports.clone = function(url, dirname) {
return new Promise((resolve, reject) => {
exec(`git clone --depth 1 ${url} ${dirname}`, error => {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd use the execa pacakge and fs-extra for promise apis (easier then rolling our own every time)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually avoid third party if requirments are trivial :)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why maintain the code tho? That's the advantage to the big ecosystem :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True :)

if (error) {
reject(error);
} else {
resolve(error);
}
});
});
};

module.exports.silenceTests = filter => {
babel;
};
32 changes: 32 additions & 0 deletions scripts/jest/config.react-dom-test-suite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// const packageJSON = require('../../package.json');
// module.exports = Object.assign(
// {},
// // packageJSON.jest,
// {
// transform:{
// '.*': require.resolve('./preprocess.react-test-suite.js')
// },
// setupFiles: ['./test/setup.js'],
// moduleNameMapper: {
// 'react-dom': '<rootDir>/lib/index.js',
// },
// testRegex:
// 'test/react-test-suite/packages/react-dom/src/__tests__/.*\\.js$',
// rootDir: process.cwd(),
// roots: ['<rootDir>/test/react-test-suite/packages'],
// },
// );

const reactJestSourceConfig = require('../../test/react-test-suite/scripts/jest/config.source.js');

module.exports = Object.assign({}, reactJestSourceConfig, {
modulePathIgnorePatterns: [
'<rootDir>/test/react-test-suite/scripts/rollup/shims/',
'<rootDir>/test/react-test-suite/scripts/bench/',
],
moduleNameMapper: {
'react-dom': '<rootDir>/lib/index.js',
},
testRegex: '/react-dom/src/__tests__/[^/]*(\\.js)$',
roots: ['<rootDir>/test/react-test-suite/packages'],
});
25 changes: 25 additions & 0 deletions scripts/jest/preprocess.react-test-suite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const babel = require('babel-core');
const path = require('path');

const babelOptions = {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think you need a custom transformer here, the root babelrc will be picked up and will work. as it is jest is only running the files in __tests__ so there isn't a need to filter again in the babel transformer right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually there's no filter. L16 is just left over code. I'll remove it.

plugins: [
// For Node environment only. For builds, Rollup takes care of ESM.
require.resolve('babel-plugin-transform-es2015-modules-commonjs'),
require.resolve('babel-plugin-transform-react-jsx-source'),
require.resolve('babel-plugin-transform-async-to-generator'),
],
retainLines: true,
};

module.exports = {
process: function(src, filePath) {
const isTestFile = !!filePath.match(/\/__tests__\//);
return babel.transform(
src,
Object.assign(
{ filename: path.relative(process.cwd(), filePath) },
babelOptions,
),
).code;
},
};