-
Notifications
You must be signed in to change notification settings - Fork 47.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d57c1a4
commit 7dfdd14
Showing
62 changed files
with
11,612 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
node_modules | ||
|
||
# testing | ||
coverage | ||
|
||
# production | ||
build | ||
public/scheduler-unstable_mock.development.js | ||
public/scheduler-unstable_mock.production.min.js | ||
public/react.development.js | ||
public/react.production.min.js | ||
public/react-dom.development.js | ||
public/react-dom.production.min.js | ||
public/react-dom-server.browser.development.js | ||
public/react-dom-server.browser.production.min.js | ||
public/react-dom-test-utils.development.js | ||
public/react-dom-test-utils.production.min.js | ||
|
||
# misc | ||
.DS_Store | ||
.env | ||
npm-debug.log |
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,21 @@ | ||
## Overview | ||
|
||
Use nvm to switch node versions. | ||
|
||
### Node <15 | ||
- Node<15 | ||
- Node<15 + jsdom | ||
- Node<15 + jest + jest-environment-node | ||
- Node<15 + jest + jest-environment-node + jsdom | ||
- Node<15 + jest + jest-environment-jsdom + jsdom | ||
|
||
### Node >= 15 | ||
- Node>=15 | ||
- Node>=15 + jsdom | ||
- Node>=15 + jest + jest-environment-node | ||
- Node>=15 + jest + jest-environment-node + jsdom | ||
- Node>=15 + jest + jest-environment-jsdom + jsdom | ||
|
||
### Other | ||
- Browser | ||
- React Native |
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,138 @@ | ||
/** @jest-environment node */ | ||
|
||
|
||
const { spawn, exec } = require('child_process'); | ||
|
||
const NODE_14_TEST_CASES = [ | ||
['node-14'], | ||
["node-14"], | ||
["node-14-jsdom"], | ||
["node-14-jest-env-node"], | ||
["node-14-jest-env-node-jsdom"], | ||
["node-14-jest-env-jsdom"] | ||
] | ||
|
||
const NODE_15_TEST_CASES = [ | ||
['node-15'], | ||
["node-15"], | ||
["node-15-jsdom"], | ||
["node-15-jest-env-node"], | ||
["node-15-jest-env-node-jsdom"], | ||
["node-15-jest-env-jsdom"] | ||
]; | ||
|
||
describe.each([['Node <15', NODE_14_TEST_CASES], ['Node 15', NODE_15_TEST_CASES]])('$s', (label, cases) => { | ||
if (process.env.DEBUG) { | ||
console.log('Running', label); | ||
} | ||
|
||
it.each(cases)('%s', (command, done) => { | ||
const test = spawn('yarn', [command], {detached: true}); | ||
let finished = false; | ||
let timeout; | ||
|
||
function debug(...args) { | ||
if (!finished && process.env.DEBUG) { | ||
console.log(command, ...args); | ||
} | ||
} | ||
|
||
debug(`testing ${command}...`); | ||
|
||
function processResult(reason) { | ||
if (!finished) { | ||
finished = true; | ||
clearTimeout(timeout); | ||
try { | ||
expect(command).toPass(reason); | ||
} finally { | ||
done(); | ||
} | ||
|
||
} | ||
} | ||
|
||
test.stderr.on('data', (data) => { | ||
debug('err', data.toString()); | ||
if (data.toString().indexOf('STARTED') >= 0) { | ||
if (!timeout) { | ||
debug('schduling stderr timeout'); | ||
timeout = setTimeout(() => { | ||
debug('timed out in stderr, killing'); | ||
test.kill('SIGKILL'); | ||
processResult('TIMEOUT'); | ||
}, 10000); | ||
} else { | ||
debug('timeout already set'); | ||
} | ||
} | ||
}); | ||
test.stdout.on('data', (data) => { | ||
debug('out', data.toString()); | ||
if (data.toString().indexOf('STARTED') >= 0) { | ||
if (!timeout) { | ||
debug('schduling stdout timeout'); | ||
timeout = setTimeout(() => { | ||
debug('timed out in out, killing'); | ||
process.kill(-test.pid); | ||
processResult('TIMEOUT'); | ||
}, 10000); | ||
} else { | ||
debug('timeout already set'); | ||
} | ||
} | ||
}); | ||
test.on('close', (code) => { | ||
debug('closed', code); | ||
|
||
if (code !== 0) { | ||
processResult('FAILED'); | ||
} else { | ||
processResult('SUCCESS'); | ||
} | ||
|
||
}); | ||
|
||
test.on('error', (err) => { | ||
debug('error', err); | ||
processResult('ERROR'); | ||
}); | ||
|
||
test.on('SIGKILL', () => { | ||
debug('killed'); | ||
processResult('KILLED'); | ||
}); | ||
}); | ||
}); | ||
|
||
expect.extend({ | ||
toPass(command, reason) { | ||
const pass = reason === 'SUCCESS'; | ||
function getCommand() { | ||
return `(yarn ${command})` | ||
} | ||
if (pass) { | ||
return { | ||
message: () => | ||
`expected ${command} not to pass`, | ||
pass: true, | ||
}; | ||
} else { | ||
return { | ||
message: () => { | ||
switch(reason) { | ||
case 'FAILED': | ||
return `expected ${command} to pass but it failed ${getCommand()}`; | ||
case 'TIMEOUT': | ||
return `expected ${command} to pass but it hung ${getCommand()}`; | ||
case 'ERROR': | ||
return `expected ${command} to pass but it errored ${getCommand()}`; | ||
default: | ||
return `expected ${command} to pass but it failed for an unknown reason ${reason}`; | ||
} | ||
}, | ||
pass: false, | ||
}; | ||
} | ||
}, | ||
}); |
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,5 @@ | ||
{ | ||
"ignore": [], | ||
"presets": ["@babel/preset-env", "@babel/preset-flow", "@babel/preset-react"] | ||
|
||
} |
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,39 @@ | ||
/** @jest-environment jsdom */ | ||
|
||
console.log('STARTED'); | ||
|
||
beforeEach(() => { | ||
jest.resetModules(); | ||
}) | ||
|
||
it('should not crash in jsdom env', () => { | ||
require('scheduler'); | ||
}); | ||
|
||
it('should not crash in jsdom env with jest jsdom', () => { | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
function Effecty() { | ||
React.useEffect(() => {}, []); | ||
return null; | ||
} | ||
|
||
ReactDOM.render(<Effecty />, document.createElement('div')); | ||
}); | ||
|
||
it('should not crash in jsdom env with jsdom', () => { | ||
var { JSDOM } = require('jsdom'); | ||
var { window } = new JSDOM(); | ||
global.window = window; | ||
global.document = window.document; | ||
global.navigator = {userAgent: ''} | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
|
||
function Effecty() { | ||
React.useEffect(() => {}, []); | ||
return null; | ||
} | ||
|
||
ReactDOM.render(<Effecty />, document.createElement('div')); | ||
}); |
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,19 @@ | ||
/** @jest-environment node */ | ||
|
||
console.log('STARTED'); | ||
|
||
it('should not crash in node env with jsdom', () => { | ||
var { JSDOM } = require('jsdom'); | ||
var { window } = new JSDOM(); | ||
global.window = window; | ||
global.document = window.document; | ||
global.navigator = {userAgent: ''} | ||
const React = require('react'); | ||
const ReactDOM = require('react-dom'); | ||
function Effecty() { | ||
React.useEffect(() => {}, []); | ||
return null; | ||
} | ||
|
||
ReactDOM.render(<Effecty />, document.createElement('div')); | ||
}); |
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,9 @@ | ||
/** @jest-environment node */ | ||
|
||
console.log('STARTED'); | ||
|
||
it('should not crash in node env', () => { | ||
global.window = global; | ||
|
||
require('scheduler'); | ||
}); |
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,8 @@ | ||
console.log('STARTED'); | ||
|
||
var { JSDOM } = require('jsdom'); | ||
var { window } = new JSDOM(); | ||
global.window = window; | ||
global.document = window.document; | ||
|
||
require('scheduler'); |
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,6 @@ | ||
global.__VARIANT__ = true; | ||
|
||
console.log('STARTED'); | ||
|
||
global.window = global; // simulate JSDOM | ||
require('scheduler'); |
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,46 @@ | ||
{ | ||
"name": "react-fixtures", | ||
"version": "0.1.0", | ||
"private": true, | ||
"devDependencies": { | ||
"@babel/core": "^7.13.10", | ||
"@babel/plugin-transform-regenerator": "^7.12.13", | ||
"@babel/preset-flow": "^7.12.13", | ||
"@babel/preset-react": "^7.12.13", | ||
"@babel/register": "^7.13.8" | ||
}, | ||
"dependencies": { | ||
"jest": "^26.6.3", | ||
"node-14": "npm:node@14", | ||
"node-15": "npm:node@15", | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0", | ||
"scheduler": "^0.20.1" | ||
}, | ||
"scripts": { | ||
"test-all": "jest all.js", | ||
"node-14": "node_modules/node-14/bin/node node/test-node.js", | ||
"node-14-jsdom": "node_modules/node-14/bin/node node/test-jsdom.js", | ||
"node-14-jest-env-node": "node_modules/node-14/bin/node node_modules/jest-cli/bin/jest.js jest/test-jsdom.js", | ||
"node-14-jest-env-node-jsdom": "node_modules/node-14/bin/node node_modules/jest-cli/bin/jest.js jest/test-node-jsdom.js", | ||
"node-14-jest-env-jsdom": "node_modules/node-14/bin/node node_modules/jest-cli/bin/jest.js jest/test-jsdom.js", | ||
"node-15": "node_modules/node-15/bin/node node/test-node.js", | ||
"node-15-jsdom": "node_modules/node-15/bin/node node/test-jsdom.js", | ||
"node-15-jest-env-node": "node_modules/node-15/bin/node node_modules/jest-cli/bin/jest.js jest/test-jsdom.js", | ||
"node-15-jest-env-node-jsdom": "node_modules/node-15/bin/node node_modules/jest-cli/bin/jest.js jest/test-node-jsdom.js", | ||
"node-15-jest-env-jsdom": "node_modules/node-15/bin/node node_modules/jest-cli/bin/jest.js jest/test-jsdom.js", | ||
"main": "cp -a ./schedulers/main/. node_modules/scheduler", | ||
"pr": "cp -a ./schedulers/pr/. node_modules/scheduler", | ||
"stable": "cp -a ./schedulers/stable/. node_modules/" | ||
}, | ||
"jest": { | ||
"testTimeout": 20000, | ||
"testMatch": [ | ||
"**/jest/*.js", | ||
"**/__tests__/*.js" | ||
], | ||
"modulePathIgnorePatterns": [ | ||
"<rootDir>[/\\\\](schedulers)[/\\\\]" | ||
] | ||
} | ||
} |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Facebook, Inc. and its affiliates. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,9 @@ | ||
# `scheduler` | ||
|
||
This is a package for cooperative scheduling in a browser environment. It is currently used internally by React, but we plan to make it more generic. | ||
|
||
The public API for this package is not yet finalized. | ||
|
||
### Thanks | ||
|
||
The React team thanks [Anton Podviaznikov](https://podviaznikov.com/) for donating the `scheduler` package name. |
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,8 @@ | ||
{ | ||
"branch": "17.0.1", | ||
"buildNumber": "222790", | ||
"checksum": "addb3df", | ||
"commit": "8e5adfbd7", | ||
"environment": "ci", | ||
"reactVersion": "17.0.0-8e5adfbd7" | ||
} |
Oops, something went wrong.