From 27985a273173a7e3f9ee239c814b5713f8fdfaff Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Fri, 1 Jun 2018 23:02:41 -0700 Subject: [PATCH 01/44] convert mocha tests to jest --- .../kitchensink/.template.dependencies.json | 2 +- .../kitchensink/integration/env.test.js | 31 ++++---- .../kitchensink/integration/initDOM.js | 2 +- .../kitchensink/integration/syntax.test.js | 45 ++++++----- .../kitchensink/integration/webpack.test.js | 75 ++++++++++--------- packages/react-scripts/template/README.md | 2 +- tasks/e2e-kitchensink.sh | 8 +- 7 files changed, 81 insertions(+), 84 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 0a42b7d4cd1..720d3abe99d 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -6,7 +6,7 @@ "bootstrap": "4.1.0", "chai": "3.5.0", "jsdom": "9.8.3", - "mocha": "3.2.0", + "jest": "23.1.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", diff --git a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js index 43badcbde8e..8a8dc5d28ac 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import { expect } from 'chai'; import initDOM from './initDOM'; describe('Integration', () => { @@ -15,23 +14,23 @@ describe('Integration', () => { expect( doc.getElementById('feature-file-env-original-1').textContent - ).to.equal('from-original-env-1'); + ).toBe('from-original-env-1'); expect( doc.getElementById('feature-file-env-original-2').textContent - ).to.equal('override-from-original-local-env-2'); + ).toBe('override-from-original-local-env-2'); if (process.env.NODE_ENV === 'production') { - expect(doc.getElementById('feature-file-env').textContent).to.equal( + expect(doc.getElementById('feature-file-env').textContent).toBe( 'production' ); - expect(doc.getElementById('feature-file-env-x').textContent).to.equal( + expect(doc.getElementById('feature-file-env-x').textContent).toBe( 'x-from-production-env' ); } else { - expect(doc.getElementById('feature-file-env').textContent).to.equal( + expect(doc.getElementById('feature-file-env').textContent).toBe( 'development' ); - expect(doc.getElementById('feature-file-env-x').textContent).to.equal( + expect(doc.getElementById('feature-file-env-x').textContent).toBe( 'x-from-development-env' ); } @@ -40,9 +39,7 @@ describe('Integration', () => { it('NODE_PATH', async () => { const doc = await initDOM('node-path'); - expect( - doc.getElementById('feature-node-path').childElementCount - ).to.equal(4); + expect(doc.getElementById('feature-node-path').childElementCount).toBe(4); }); it('PUBLIC_URL', async () => { @@ -52,12 +49,12 @@ describe('Integration', () => { process.env.NODE_ENV === 'development' ? '' : 'http://www.example.org/spa'; - expect(doc.getElementById('feature-public-url').textContent).to.equal( + expect(doc.getElementById('feature-public-url').textContent).toBe( `${prefix}.` ); expect( doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href') - ).to.equal(`${prefix}/favicon.ico`); + ).toBe(`${prefix}/favicon.ico`); }); it('shell env variables', async () => { @@ -65,24 +62,24 @@ describe('Integration', () => { expect( doc.getElementById('feature-shell-env-variables').textContent - ).to.equal('fromtheshell.'); + ).toBe('fromtheshell.'); }); it('expand .env variables', async () => { const doc = await initDOM('expand-env-variables'); - expect(doc.getElementById('feature-expand-env-1').textContent).to.equal( + expect(doc.getElementById('feature-expand-env-1').textContent).toBe( 'basic' ); - expect(doc.getElementById('feature-expand-env-2').textContent).to.equal( + expect(doc.getElementById('feature-expand-env-2').textContent).toBe( 'basic' ); - expect(doc.getElementById('feature-expand-env-3').textContent).to.equal( + expect(doc.getElementById('feature-expand-env-3').textContent).toBe( 'basic' ); expect( doc.getElementById('feature-expand-env-existing').textContent - ).to.equal('fromtheshell'); + ).toBe('fromtheshell'); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index 36e8de9999f..e17bd06c0cb 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -50,7 +50,7 @@ if (process.env.E2E_FILE) { it.only('can run jsdom (at least one of "E2E_FILE" or "E2E_URL" environment variables must be provided)', () => { expect( new Error("This isn't the error you are looking for.") - ).to.be.undefined(); + ).to.BeUndefined(); }); } diff --git a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js index 82e2c9e0db2..57ef183b613 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import { expect } from 'chai'; import initDOM from './initDOM'; describe('Integration', () => { @@ -15,23 +14,23 @@ describe('Integration', () => { expect( doc.getElementById('feature-array-destructuring').childElementCount - ).to.equal(4); + ).toBe(4); }); it('array spread', async () => { const doc = await initDOM('array-spread'); - expect( - doc.getElementById('feature-array-spread').childElementCount - ).to.equal(4); + expect(doc.getElementById('feature-array-spread').childElementCount).toBe( + 4 + ); }); it('async/await', async () => { const doc = await initDOM('async-await'); - expect( - doc.getElementById('feature-async-await').childElementCount - ).to.equal(4); + expect(doc.getElementById('feature-async-await').childElementCount).toBe( + 4 + ); }); it('class properties', async () => { @@ -39,7 +38,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-class-properties').childElementCount - ).to.equal(4); + ).toBe(4); }); it('computed properties', async () => { @@ -47,7 +46,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-computed-properties').childElementCount - ).to.equal(4); + ).toBe(4); }); it('custom interpolation', async () => { @@ -55,7 +54,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-custom-interpolation').childElementCount - ).to.equal(4); + ).toBe(4); }); it('default parameters', async () => { @@ -63,7 +62,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-default-parameters').childElementCount - ).to.equal(4); + ).toBe(4); }); it('destructuring and await', async () => { @@ -71,15 +70,15 @@ describe('Integration', () => { expect( doc.getElementById('feature-destructuring-and-await').childElementCount - ).to.equal(4); + ).toBe(4); }); it('generators', async () => { const doc = await initDOM('generators'); - expect( - doc.getElementById('feature-generators').childElementCount - ).to.equal(4); + expect(doc.getElementById('feature-generators').childElementCount).toBe( + 4 + ); }); it('object destructuring', async () => { @@ -87,7 +86,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-destructuring').childElementCount - ).to.equal(4); + ).toBe(4); }); it('object spread', async () => { @@ -95,15 +94,13 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-spread').childElementCount - ).to.equal(4); + ).toBe(4); }); it('promises', async () => { const doc = await initDOM('promises'); - expect(doc.getElementById('feature-promises').childElementCount).to.equal( - 4 - ); + expect(doc.getElementById('feature-promises').childElementCount).toBe(4); }); it('rest + default', async () => { @@ -111,7 +108,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-and-default').childElementCount - ).to.equal(4); + ).toBe(4); }); it('rest parameters', async () => { @@ -119,7 +116,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-parameters').childElementCount - ).to.equal(4); + ).toBe(4); }); it('template interpolation', async () => { @@ -127,7 +124,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-template-interpolation').childElementCount - ).to.equal(4); + ).toBe(4); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index ff3d383219d..a682edbfcb3 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -5,46 +5,48 @@ * LICENSE file in the root directory of this source tree. */ -import { expect } from 'chai'; import initDOM, { resourceLoader } from './initDOM'; import url from 'url'; const matchCSS = (doc, regexes) => { if (process.env.E2E_FILE) { - const elements = doc.getElementsByTagName('link'); - let href = ""; - for (const elem of elements) { - if (elem.rel === 'stylesheet') { - href = elem.href; - } + const elements = doc.getElementsByTagName('link'); + let href = ''; + for (const elem of elements) { + if (elem.rel === 'stylesheet') { + href = elem.href; } - resourceLoader( - { url: url.parse(href) }, - (_, textContent) => { - for (const regex of regexes) { - expect(textContent).to.match(regex); - } - } - ); - + } + resourceLoader({ url: url.parse(href) }, (_, textContent) => { + for (const regex of regexes) { + expect(textContent).toMatch(regex); + } + }); } else { for (let i = 0; i < regexes.length; ++i) { - expect(doc.getElementsByTagName('style')[i].textContent.replace(/\s/g, '')).to.match(regexes[i]); + expect( + doc.getElementsByTagName('style')[i].textContent.replace(/\s/g, '') + ).toMatch(regexes[i]); } } -} +}; describe('Integration', () => { describe('Webpack plugins', () => { it('css inclusion', async () => { const doc = await initDOM('css-inclusion'); - matchCSS(doc, [/html\{/, /#feature-css-inclusion\{background:.+;color:.+}/]); + matchCSS(doc, [ + /html\{/, + /#feature-css-inclusion\{background:.+;color:.+}/, + ]); }); it('css modules inclusion', async () => { const doc = await initDOM('css-modules-inclusion'); - matchCSS(doc, [/.+style_cssModulesInclusion__.+\{background:.+;color:.+}/, - /.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/]); + matchCSS(doc, [ + /.+style_cssModulesInclusion__.+\{background:.+;color:.+}/, + /.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/, + ]); }); it('scss inclusion', async () => { @@ -54,9 +56,10 @@ describe('Integration', () => { it('scss modules inclusion', async () => { const doc = await initDOM('scss-modules-inclusion'); - matchCSS(doc, [/.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/, - /.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/]); - + matchCSS(doc, [ + /.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/, + /.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/, + ]); }); it('sass inclusion', async () => { @@ -66,8 +69,10 @@ describe('Integration', () => { it('sass modules inclusion', async () => { const doc = await initDOM('sass-modules-inclusion'); - matchCSS(doc, [/.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, - /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/]); + matchCSS(doc, [ + /.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, + /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/, + ]); }); it('graphql files inclusion', async () => { @@ -75,7 +80,7 @@ describe('Integration', () => { const children = doc.getElementById('graphql-inclusion').children; // .graphql - expect(children[0].textContent.replace(/\s/g, '')).to.equal( + expect(children[0].textContent.replace(/\s/g, '')).toBe( '{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}' ); }); @@ -83,7 +88,7 @@ describe('Integration', () => { it('image inclusion', async () => { const doc = await initDOM('image-inclusion'); - expect(doc.getElementById('feature-image-inclusion').src).to.match( + expect(doc.getElementById('feature-image-inclusion').src).toMatch( /^data:image\/jpeg;base64.+==$/ ); }); @@ -91,7 +96,7 @@ describe('Integration', () => { it('no ext inclusion', async () => { const doc = await initDOM('no-ext-inclusion'); - expect(doc.getElementById('feature-no-ext-inclusion').href).to.match( + expect(doc.getElementById('feature-no-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/ ); }); @@ -99,7 +104,7 @@ describe('Integration', () => { it('json inclusion', async () => { const doc = await initDOM('json-inclusion'); - expect(doc.getElementById('feature-json-inclusion').textContent).to.equal( + expect(doc.getElementById('feature-json-inclusion').textContent).toBe( 'This is an abstract.' ); }); @@ -107,14 +112,14 @@ describe('Integration', () => { it('linked modules', async () => { const doc = await initDOM('linked-modules'); - expect(doc.getElementById('feature-linked-modules').textContent).to.equal( + expect(doc.getElementById('feature-linked-modules').textContent).toBe( '2.0.0' ); }); it('svg inclusion', async () => { const doc = await initDOM('svg-inclusion'); - expect(doc.getElementById('feature-svg-inclusion').src).to.match( + expect(doc.getElementById('feature-svg-inclusion').src).toMatch( /\/static\/media\/logo\..+\.svg$/ ); }); @@ -122,9 +127,7 @@ describe('Integration', () => { it('svg component', async () => { const doc = await initDOM('svg-component'); - expect(doc.getElementById('feature-svg-component').textContent).to.equal( - '' - ); + expect(doc.getElementById('feature-svg-component').textContent).toBe(''); }); it('svg in css', async () => { @@ -135,7 +138,7 @@ describe('Integration', () => { it('unknown ext inclusion', async () => { const doc = await initDOM('unknown-ext-inclusion'); - expect(doc.getElementById('feature-unknown-ext-inclusion').href).to.match( + expect(doc.getElementById('feature-unknown-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/ ); }); diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 437c9f273db..b02604cf18b 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1477,7 +1477,7 @@ import App from './App'; it('renders welcome message', () => { const wrapper = shallow(); const welcome =

Welcome to React

; - // expect(wrapper.contains(welcome)).to.equal(true); + // expect(wrapper.contains(welcome)).toBe(true); expect(wrapper.contains(welcome)).toEqual(true); }); ``` diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index b40a487ae4b..08c740c0b3e 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,7 +151,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js + node_modules/.bin/jest "integration(/|\\)*.test.*" # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -159,7 +159,7 @@ E2E_FILE=./build/index.html \ NODE_ENV=production \ BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js + node_modules/.bin/jest "integration(/|\\)*.test.*" # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -200,7 +200,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js + node_modules/.bin/jest "integration(/|\\)*.test.*" # Test "production" environment E2E_FILE=./build/index.html \ @@ -209,7 +209,7 @@ E2E_FILE=./build/index.html \ BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js + node_modules/.bin/jest "integration(/|\\)*.test.*" # Cleanup cleanup From a53f4fb58de93766ff53ed48332658ae3da7655d Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Fri, 1 Jun 2018 23:13:58 -0700 Subject: [PATCH 02/44] jest 23 --- packages/confusing-browser-globals/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 4 ++-- packages/react-scripts/package.json | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/confusing-browser-globals/package.json b/packages/confusing-browser-globals/package.json index 88767c4d0f7..8ac8abcd1db 100644 --- a/packages/confusing-browser-globals/package.json +++ b/packages/confusing-browser-globals/package.json @@ -16,6 +16,6 @@ "index.js" ], "devDependencies": { - "jest": "22.4.3" + "jest": "23.1.0" } } diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 6e49955e453..6407e370825 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -62,7 +62,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "22.4.3" + "jest": "23.1.0" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 6e7e1f3e885..f5182b115a1 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -36,7 +36,7 @@ "anser": "1.4.6", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^8.2.2", - "babel-jest": "^22.4.3", + "babel-jest": "^23.0.1", "babel-loader": "^8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", "chalk": "^2.3.2", @@ -50,7 +50,7 @@ "eslint-plugin-react": "7.8.2", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "22.4.3", + "jest": "23.1.0", "jest-fetch-mock": "1.5.0", "object-assign": "4.1.1", "promise": "8.0.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 889c14770ea..2993611c49b 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -26,7 +26,7 @@ "autoprefixer": "8.5.0", "babel-core": "7.0.0-bridge.0", "babel-eslint": "8.2.3", - "babel-jest": "22.4.3", + "babel-jest": "23.0.1", "babel-loader": "8.0.0-beta.0", "babel-plugin-named-asset-import": "^0.1.0", "babel-preset-react-app": "^3.1.1", @@ -49,7 +49,7 @@ "html-webpack-plugin": "3.2.0", "identity-obj-proxy": "3.0.0", "loader-utils": "^1.1.0", - "jest": "22.4.3", + "jest": "23.1.0", "mini-css-extract-plugin": "^0.4.0", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.3.1", From 44089108e2550db533c914b9b858f9a12759ef5c Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 2 Jun 2018 00:52:01 -0700 Subject: [PATCH 03/44] add jest configs --- .../kitchensink/.template.dependencies.json | 7 ++----- .../fixtures/kitchensink/README.md | 20 +++++++++---------- .../kitchensink/integration/initDOM.js | 5 ++--- .../kitchensink/jest.integration.config.js | 1 + .../fixtures/kitchensink/src/index.js | 1 + tasks/e2e-kitchensink.sh | 8 ++++---- 6 files changed, 19 insertions(+), 23 deletions(-) create mode 100644 packages/react-scripts/fixtures/kitchensink/jest.integration.config.js diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 720d3abe99d..b861cd71167 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,15 +1,12 @@ { "dependencies": { - "@babel/plugin-transform-modules-commonjs": "7.0.0-beta.46", - "@babel/polyfill": "7.0.0-beta.46", - "@babel/register": "7.0.0-beta.46", "bootstrap": "4.1.0", - "chai": "3.5.0", - "jsdom": "9.8.3", + "jsdom": "11.11.0", "jest": "23.1.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", + "raf": "3.4.0", "test-integrity": "1.0.0" } } diff --git a/packages/react-scripts/fixtures/kitchensink/README.md b/packages/react-scripts/fixtures/kitchensink/README.md index 4e7725ce15f..365f16b875c 100644 --- a/packages/react-scripts/fixtures/kitchensink/README.md +++ b/packages/react-scripts/fixtures/kitchensink/README.md @@ -18,11 +18,11 @@ Each time a new feature is added, it is advised to add at least one test coverin Features are categorized by their scope: - - *env*, all those which deal with environment variables (e.g. `NODE_PATH`) - - - *syntax*, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel** +* _env_, all those which deal with environment variables (e.g. `NODE_PATH`) - - *webpack*, all those which make use of webpack settings, loaders or plugins +* _syntax_, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel** + +* _webpack_, all those which make use of webpack settings, loaders or plugins ### Using it as Unit Tests @@ -41,14 +41,12 @@ Test are written in `integration/{env|syntax|webpack}.test.js`, depending on the For every test case added there is just a little chore to do: - - a `case` statement must be added in `src/App.js`, which simply perform a dynamic `import()` of the feature +* a `case` statement must be added in `src/App.js`, which simply perform a dynamic `import()` of the feature + +* add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string - - add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string - An usual flow for the test itself is something similar to: - - - add an `id` attribute in a target HTML tag in the feature itself - - since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly +* add an `id` attribute in a target HTML tag in the feature itself -These tests are run by **mocha** (why not **jest**? See [this issue](https://github.com/facebook/jest/issues/2288)) and the environments used are both `development` and `production`. +* since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index e17bd06c0cb..900d42b30a4 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -7,9 +7,8 @@ const fs = require('fs'); const http = require('http'); -const jsdom = require('jsdom'); +const jsdom = require('jsdom/lib/old-api.js'); const path = require('path'); -const { expect } = require('chai'); let getMarkup; export let resourceLoader; @@ -50,7 +49,7 @@ if (process.env.E2E_FILE) { it.only('can run jsdom (at least one of "E2E_FILE" or "E2E_URL" environment variables must be provided)', () => { expect( new Error("This isn't the error you are looking for.") - ).to.BeUndefined(); + ).toBeUndefined(); }); } diff --git a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js new file mode 100644 index 00000000000..b2d1ed86bda --- /dev/null +++ b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js @@ -0,0 +1 @@ +module.exports = { testMatch: ['**/integration/*.test.js'] }; diff --git a/packages/react-scripts/fixtures/kitchensink/src/index.js b/packages/react-scripts/fixtures/kitchensink/src/index.js index 5268eacecf9..a99001633c8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/index.js +++ b/packages/react-scripts/fixtures/kitchensink/src/index.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import 'raf/polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 08c740c0b3e..6a3dda2b5d0 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,7 +151,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest "integration(/|\\)*.test.*" + node_modules/.bin/jest --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -159,7 +159,7 @@ E2E_FILE=./build/index.html \ NODE_ENV=production \ BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest "integration(/|\\)*.test.*" + node_modules/.bin/jest --config='jest.integration.config.js' # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -200,7 +200,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest "integration(/|\\)*.test.*" + node_modules/.bin/jest --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ @@ -209,7 +209,7 @@ E2E_FILE=./build/index.html \ BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest "integration(/|\\)*.test.*" + node_modules/.bin/jest --config='jest.integration.config.js' # Cleanup cleanup From 08c7b6bd804be8b31425b31885fc65fee56dd903 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 2 Jun 2018 22:21:52 -0700 Subject: [PATCH 04/44] use material css --- .../kitchensink/.template.dependencies.json | 2 +- .../fixtures/kitchensink/README.md | 19 ++++++++++--------- .../features/webpack/assets/scss-styles.scss | 10 +++++++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index b861cd71167..1e19f6eba52 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,6 +1,6 @@ { "dependencies": { - "bootstrap": "4.1.0", + "bootstrap": "4.1.1", "jsdom": "11.11.0", "jest": "23.1.0", "node-sass": "4.8.3", diff --git a/packages/react-scripts/fixtures/kitchensink/README.md b/packages/react-scripts/fixtures/kitchensink/README.md index 365f16b875c..0e64a76aed3 100644 --- a/packages/react-scripts/fixtures/kitchensink/README.md +++ b/packages/react-scripts/fixtures/kitchensink/README.md @@ -18,11 +18,11 @@ Each time a new feature is added, it is advised to add at least one test coverin Features are categorized by their scope: -* _env_, all those which deal with environment variables (e.g. `NODE_PATH`) + - *env*, all those which deal with environment variables (e.g. `NODE_PATH`) + + - *syntax*, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel** -* _syntax_, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel** - -* _webpack_, all those which make use of webpack settings, loaders or plugins + - *webpack*, all those which make use of webpack settings, loaders or plugins ### Using it as Unit Tests @@ -41,12 +41,13 @@ Test are written in `integration/{env|syntax|webpack}.test.js`, depending on the For every test case added there is just a little chore to do: -* a `case` statement must be added in `src/App.js`, which simply perform a dynamic `import()` of the feature - -* add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string + - a `case` statement must be added in `src/App.js`, which simply perform a dynamic `import()` of the feature + - add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string + An usual flow for the test itself is something similar to: + + - add an `id` attribute in a target HTML tag in the feature itself -* add an `id` attribute in a target HTML tag in the feature itself + - since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly -* since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/scss-styles.scss b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/scss-styles.scss index 8aac77fbf6e..5a764ed2022 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/scss-styles.scss +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/scss-styles.scss @@ -1,4 +1,12 @@ -@import "~bootstrap/scss/bootstrap"; +@import "~bootstrap/scss/functions"; +@import "~bootstrap/scss/variables"; +@import "~bootstrap/scss/mixins"; + +@import "~bootstrap/scss/reboot"; +@import "~bootstrap/scss/type"; +@import "~bootstrap/scss/images"; +@import "~bootstrap/scss/code"; +@import "~bootstrap/scss/grid"; #feature-scss-inclusion { background: ghostwhite; From c9e1e754864f8b32325eec3ad85d1341b1fcee56 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 3 Jun 2018 14:36:49 -0700 Subject: [PATCH 05/44] fix windows --- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index e884518d73a..d12bf415b71 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -44,7 +44,7 @@ module.exports = (resolve, rootDir, srcRoots) => { ), }, transformIgnorePatterns: [ - '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$', + '/node_modules/.+\\.(js|jsx|mjs)$', '^.+\\.module\\.(css|sass|scss)$', ], moduleNameMapper: { From c445b9337d10c06d91635f0587b46030e2d099e4 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 3 Jun 2018 15:39:35 -0700 Subject: [PATCH 06/44] forceExit jest test --- tasks/e2e-kitchensink.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 6a3dda2b5d0..f10cd7a1600 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -146,12 +146,13 @@ PORT=3001 \ grep -q 'You can now view' <(tail -f $tmp_server_log) # Test "development" environment +# AppVeyor hangs unless we forceExit: https://github.com/facebook/jest/issues/2288 E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --config='jest.integration.config.js' --forceExit # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ From 411e01684799a9ec460ddca32d0fc3100d204c66 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 3 Jun 2018 21:06:04 -0700 Subject: [PATCH 07/44] force exit eject --- tasks/e2e-kitchensink.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index f10cd7a1600..e3f0beeb98f 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -190,6 +190,7 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ yarn test --no-cache --testPathPattern=src # Test "development" environment +# AppVeyor hangs unless we forceExit: https://github.com/facebook/jest/issues/2288 tmp_server_log=`mktemp` PORT=3002 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ @@ -201,7 +202,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --config='jest.integration.config.js' --forceExit # Test "production" environment E2E_FILE=./build/index.html \ From 737ba134241b03b40d0e9d5617912e9cbfe71395 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 3 Jun 2018 21:07:18 -0700 Subject: [PATCH 08/44] test --- .../fixtures/kitchensink/integration/webpack.test.js | 2 +- tasks/e2e-kitchensink.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index a682edbfcb3..19f70fea12b 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -71,7 +71,7 @@ describe('Integration', () => { const doc = await initDOM('sass-modules-inclusion'); matchCSS(doc, [ /.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, - /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/, + /.+assets_sassModulesIndexInclusion.+\{backkground:.+;color:.+}/, ]); }); diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index e3f0beeb98f..94fd4369580 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -152,7 +152,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' --forceExit + node_modules/.bin/jest --config='jest.integration.config.js' --forceExit --detectOpenHandles # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -202,7 +202,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' --forceExit + node_modules/.bin/jest --config='jest.integration.config.js' --forceExit --detectOpenHandles # Test "production" environment E2E_FILE=./build/index.html \ From 152d05976a56772de6032a3a752786876f59458e Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Mon, 4 Jun 2018 00:02:12 -0700 Subject: [PATCH 09/44] test --- .../kitchensink/.template.dependencies.json | 1 - .../kitchensink/integration/env.test.js | 5 +++++ .../fixtures/kitchensink/integration/initDOM.js | 1 + .../kitchensink/integration/syntax.test.js | 15 +++++++++++++++ .../kitchensink/integration/webpack.test.js | 17 ++++++++++++++++- .../fixtures/kitchensink/src/index.js | 1 - tasks/e2e-kitchensink.sh | 4 ++-- 7 files changed, 39 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 1e19f6eba52..90a7ee89429 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -6,7 +6,6 @@ "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", - "raf": "3.4.0", "test-integrity": "1.0.0" } } diff --git a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js index 8a8dc5d28ac..79de16706dc 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js @@ -34,12 +34,14 @@ describe('Integration', () => { 'x-from-development-env' ); } + doc.defaultView.close(); }); it('NODE_PATH', async () => { const doc = await initDOM('node-path'); expect(doc.getElementById('feature-node-path').childElementCount).toBe(4); + doc.defaultView.close(); }); it('PUBLIC_URL', async () => { @@ -55,6 +57,7 @@ describe('Integration', () => { expect( doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href') ).toBe(`${prefix}/favicon.ico`); + doc.defaultView.close(); }); it('shell env variables', async () => { @@ -63,6 +66,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-shell-env-variables').textContent ).toBe('fromtheshell.'); + doc.defaultView.close(); }); it('expand .env variables', async () => { @@ -80,6 +84,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-expand-env-existing').textContent ).toBe('fromtheshell'); + doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index 900d42b30a4..f298a7add59 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -62,6 +62,7 @@ export default feature => win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true), deferClose: true, resourceLoader, + pretendToBeVisual: true, url: `${host}#${feature}`, virtualConsole: jsdom.createVirtualConsole().sendTo(console), }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js index 57ef183b613..54920726fa5 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js @@ -15,6 +15,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-array-destructuring').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('array spread', async () => { @@ -23,6 +24,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-array-spread').childElementCount).toBe( 4 ); + doc.defaultView.close(); }); it('async/await', async () => { @@ -31,6 +33,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-async-await').childElementCount).toBe( 4 ); + doc.defaultView.close(); }); it('class properties', async () => { @@ -39,6 +42,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-class-properties').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('computed properties', async () => { @@ -47,6 +51,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-computed-properties').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('custom interpolation', async () => { @@ -55,6 +60,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-custom-interpolation').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('default parameters', async () => { @@ -63,6 +69,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-default-parameters').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('destructuring and await', async () => { @@ -71,6 +78,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-destructuring-and-await').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('generators', async () => { @@ -79,6 +87,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-generators').childElementCount).toBe( 4 ); + doc.defaultView.close(); }); it('object destructuring', async () => { @@ -87,6 +96,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-destructuring').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('object spread', async () => { @@ -95,12 +105,14 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-spread').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('promises', async () => { const doc = await initDOM('promises'); expect(doc.getElementById('feature-promises').childElementCount).toBe(4); + doc.defaultView.close(); }); it('rest + default', async () => { @@ -109,6 +121,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-and-default').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('rest parameters', async () => { @@ -117,6 +130,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-parameters').childElementCount ).toBe(4); + doc.defaultView.close(); }); it('template interpolation', async () => { @@ -125,6 +139,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-template-interpolation').childElementCount ).toBe(4); + doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index 19f70fea12b..ebd830dfaaa 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -39,6 +39,7 @@ describe('Integration', () => { /html\{/, /#feature-css-inclusion\{background:.+;color:.+}/, ]); + doc.defaultView.close(); }); it('css modules inclusion', async () => { @@ -47,11 +48,13 @@ describe('Integration', () => { /.+style_cssModulesInclusion__.+\{background:.+;color:.+}/, /.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/, ]); + doc.defaultView.close(); }); it('scss inclusion', async () => { const doc = await initDOM('scss-inclusion'); matchCSS(doc, [/#feature-scss-inclusion\{background:.+;color:.+}/]); + doc.defaultView.close(); }); it('scss modules inclusion', async () => { @@ -60,19 +63,22 @@ describe('Integration', () => { /.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/, /.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/, ]); + doc.defaultView.close(); }); it('sass inclusion', async () => { const doc = await initDOM('sass-inclusion'); matchCSS(doc, [/#feature-sass-inclusion\{background:.+;color:.+}/]); + doc.defaultView.close(); }); it('sass modules inclusion', async () => { const doc = await initDOM('sass-modules-inclusion'); matchCSS(doc, [ /.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, - /.+assets_sassModulesIndexInclusion.+\{backkground:.+;color:.+}/, + /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/, ]); + doc.defaultView.close(); }); it('graphql files inclusion', async () => { @@ -83,6 +89,7 @@ describe('Integration', () => { expect(children[0].textContent.replace(/\s/g, '')).toBe( '{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}' ); + doc.defaultView.close(); }); it('image inclusion', async () => { @@ -91,6 +98,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-image-inclusion').src).toMatch( /^data:image\/jpeg;base64.+==$/ ); + doc.defaultView.close(); }); it('no ext inclusion', async () => { @@ -99,6 +107,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-no-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/ ); + doc.defaultView.close(); }); it('json inclusion', async () => { @@ -107,6 +116,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-json-inclusion').textContent).toBe( 'This is an abstract.' ); + doc.defaultView.close(); }); it('linked modules', async () => { @@ -115,6 +125,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-linked-modules').textContent).toBe( '2.0.0' ); + doc.defaultView.close(); }); it('svg inclusion', async () => { @@ -122,17 +133,20 @@ describe('Integration', () => { expect(doc.getElementById('feature-svg-inclusion').src).toMatch( /\/static\/media\/logo\..+\.svg$/ ); + doc.defaultView.close(); }); it('svg component', async () => { const doc = await initDOM('svg-component'); expect(doc.getElementById('feature-svg-component').textContent).toBe(''); + doc.defaultView.close(); }); it('svg in css', async () => { const doc = await initDOM('svg-in-css'); matchCSS(doc, [/\/static\/media\/logo\..+\.svg/]); + doc.defaultView.close(); }); it('unknown ext inclusion', async () => { @@ -141,6 +155,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-unknown-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/ ); + doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/index.js b/packages/react-scripts/fixtures/kitchensink/src/index.js index a99001633c8..5268eacecf9 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/index.js +++ b/packages/react-scripts/fixtures/kitchensink/src/index.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import 'raf/polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 94fd4369580..e8fb75294ef 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -152,7 +152,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' --forceExit --detectOpenHandles + node_modules/.bin/jest --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -202,7 +202,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' --forceExit --detectOpenHandles + node_modules/.bin/jest --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ From 230931f4e8e26456ad9fb0b6f185a2da368c18ca Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 9 Jun 2018 18:22:29 -0700 Subject: [PATCH 10/44] retrigger test --- .../fixtures/monorepos/packages/comp1/package.json | 4 ++-- .../fixtures/monorepos/packages/comp2/package.json | 4 ++-- .../fixtures/monorepos/packages/cra-app1/package.json | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json b/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json index baa4c31dc71..ea6b52e65db 100644 --- a/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json +++ b/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json @@ -4,7 +4,7 @@ "main": "index.js", "license": "MIT", "devDependencies": { - "react": "^16.2.0", - "react-dom": "^16.2.0" + "react": "^16.4.0", + "react-dom": "^16.4.0" } } diff --git a/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json b/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json index 329b14077ba..c905edc726a 100644 --- a/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json +++ b/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json @@ -4,8 +4,8 @@ "comp1": "^1.0.0" }, "devDependencies": { - "react": "^16.2.0", - "react-dom": "^16.2.0" + "react": "^16.4.0", + "react-dom": "^16.4.0" }, "version": "1.0.0", "main": "index.js", diff --git a/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json b/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json index 218edb79d6b..4815ebc873e 100644 --- a/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json +++ b/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json @@ -4,8 +4,8 @@ "private": true, "dependencies": { "comp2": "^1.0.0", - "react": "^16.2.0", - "react-dom": "^16.2.0" + "react": "^16.4.0", + "react-dom": "^16.4.0" }, "devDependencies": { "react-scripts": "latest" From 9d6e0cf9097c259fc9e9f07f8c4f12bf281fdabd Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 9 Jun 2018 19:52:49 -0700 Subject: [PATCH 11/44] remove appveyor comment --- tasks/e2e-kitchensink.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index e8fb75294ef..6a3dda2b5d0 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -146,7 +146,6 @@ PORT=3001 \ grep -q 'You can now view' <(tail -f $tmp_server_log) # Test "development" environment -# AppVeyor hangs unless we forceExit: https://github.com/facebook/jest/issues/2288 E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ @@ -190,7 +189,6 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ yarn test --no-cache --testPathPattern=src # Test "development" environment -# AppVeyor hangs unless we forceExit: https://github.com/facebook/jest/issues/2288 tmp_server_log=`mktemp` PORT=3002 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ From bd6bc73307dd27b05d6e73beddc937b657a37e46 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 9 Jun 2018 20:30:10 -0700 Subject: [PATCH 12/44] try to remove pretendToBeVisual option --- .../react-scripts/fixtures/kitchensink/integration/initDOM.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index f298a7add59..900d42b30a4 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -62,7 +62,6 @@ export default feature => win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true), deferClose: true, resourceLoader, - pretendToBeVisual: true, url: `${host}#${feature}`, virtualConsole: jsdom.createVirtualConsole().sendTo(console), }); From d27b1c1b21c23ae07d0f531bfbf11291a08cb0c6 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 9 Jun 2018 21:25:12 -0700 Subject: [PATCH 13/44] use jsdom env --- .../fixtures/kitchensink/.template.dependencies.json | 1 - .../fixtures/kitchensink/jest.integration.config.js | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 90a7ee89429..e6add5a4aa8 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,7 +1,6 @@ { "dependencies": { "bootstrap": "4.1.1", - "jsdom": "11.11.0", "jest": "23.1.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", diff --git a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js index b2d1ed86bda..70ebf7e580e 100644 --- a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js +++ b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js @@ -1 +1,4 @@ -module.exports = { testMatch: ['**/integration/*.test.js'] }; +module.exports = { + testEnvironment: 'jsdom', + testMatch: ['**/integration/*.test.js'], +}; From a3b37ef19d1fa41bc9757f0c85fadc928b7a4321 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 9 Jun 2018 22:34:55 -0700 Subject: [PATCH 14/44] test environment --- .../react-scripts/fixtures/kitchensink/integration/initDOM.js | 1 + .../fixtures/kitchensink/jest.integration.config.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index 900d42b30a4..e807888d397 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -61,6 +61,7 @@ export default feature => created: (_, win) => win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true), deferClose: true, + pretendToBeVisual: true, resourceLoader, url: `${host}#${feature}`, virtualConsole: jsdom.createVirtualConsole().sendTo(console), diff --git a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js index 70ebf7e580e..fc778892493 100644 --- a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js +++ b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js @@ -1,4 +1,4 @@ module.exports = { - testEnvironment: 'jsdom', + testEnvironment: 'node', testMatch: ['**/integration/*.test.js'], }; From 987df9e38ea08e7ffdccd4cd92c9aec4986d255f Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 00:41:49 -0700 Subject: [PATCH 15/44] no cache --- tasks/e2e-kitchensink.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 6a3dda2b5d0..bda3c3bc069 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,7 +151,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -159,7 +159,7 @@ E2E_FILE=./build/index.html \ NODE_ENV=production \ BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -200,7 +200,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ @@ -209,7 +209,7 @@ E2E_FILE=./build/index.html \ BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # Cleanup cleanup From 3f881c6e03cabc8fc71124361d0c10e1c9cb4d65 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 01:33:13 -0700 Subject: [PATCH 16/44] test no close --- .../kitchensink/integration/env.test.js | 10 +++---- .../kitchensink/integration/syntax.test.js | 30 +++++++++---------- .../kitchensink/integration/webpack.test.js | 30 +++++++++---------- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js index 79de16706dc..03a28a97a36 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js @@ -34,14 +34,14 @@ describe('Integration', () => { 'x-from-development-env' ); } - doc.defaultView.close(); + // doc.defaultView.close(); }); it('NODE_PATH', async () => { const doc = await initDOM('node-path'); expect(doc.getElementById('feature-node-path').childElementCount).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('PUBLIC_URL', async () => { @@ -57,7 +57,7 @@ describe('Integration', () => { expect( doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href') ).toBe(`${prefix}/favicon.ico`); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('shell env variables', async () => { @@ -66,7 +66,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-shell-env-variables').textContent ).toBe('fromtheshell.'); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('expand .env variables', async () => { @@ -84,7 +84,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-expand-env-existing').textContent ).toBe('fromtheshell'); - doc.defaultView.close(); + // doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js index 54920726fa5..e2011bbefea 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js @@ -15,7 +15,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-array-destructuring').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('array spread', async () => { @@ -24,7 +24,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-array-spread').childElementCount).toBe( 4 ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('async/await', async () => { @@ -33,7 +33,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-async-await').childElementCount).toBe( 4 ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('class properties', async () => { @@ -42,7 +42,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-class-properties').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('computed properties', async () => { @@ -51,7 +51,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-computed-properties').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('custom interpolation', async () => { @@ -60,7 +60,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-custom-interpolation').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('default parameters', async () => { @@ -69,7 +69,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-default-parameters').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('destructuring and await', async () => { @@ -78,7 +78,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-destructuring-and-await').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('generators', async () => { @@ -87,7 +87,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-generators').childElementCount).toBe( 4 ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('object destructuring', async () => { @@ -96,7 +96,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-destructuring').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('object spread', async () => { @@ -105,14 +105,14 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-spread').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('promises', async () => { const doc = await initDOM('promises'); expect(doc.getElementById('feature-promises').childElementCount).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('rest + default', async () => { @@ -121,7 +121,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-and-default').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('rest parameters', async () => { @@ -130,7 +130,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-parameters').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('template interpolation', async () => { @@ -139,7 +139,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-template-interpolation').childElementCount ).toBe(4); - doc.defaultView.close(); + // doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index ebd830dfaaa..f870f640a0c 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -39,7 +39,7 @@ describe('Integration', () => { /html\{/, /#feature-css-inclusion\{background:.+;color:.+}/, ]); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('css modules inclusion', async () => { @@ -48,13 +48,13 @@ describe('Integration', () => { /.+style_cssModulesInclusion__.+\{background:.+;color:.+}/, /.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/, ]); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('scss inclusion', async () => { const doc = await initDOM('scss-inclusion'); matchCSS(doc, [/#feature-scss-inclusion\{background:.+;color:.+}/]); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('scss modules inclusion', async () => { @@ -63,13 +63,13 @@ describe('Integration', () => { /.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/, /.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/, ]); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('sass inclusion', async () => { const doc = await initDOM('sass-inclusion'); matchCSS(doc, [/#feature-sass-inclusion\{background:.+;color:.+}/]); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('sass modules inclusion', async () => { @@ -78,7 +78,7 @@ describe('Integration', () => { /.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/, ]); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('graphql files inclusion', async () => { @@ -89,7 +89,7 @@ describe('Integration', () => { expect(children[0].textContent.replace(/\s/g, '')).toBe( '{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}' ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('image inclusion', async () => { @@ -98,7 +98,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-image-inclusion').src).toMatch( /^data:image\/jpeg;base64.+==$/ ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('no ext inclusion', async () => { @@ -107,7 +107,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-no-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/ ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('json inclusion', async () => { @@ -116,7 +116,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-json-inclusion').textContent).toBe( 'This is an abstract.' ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('linked modules', async () => { @@ -125,7 +125,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-linked-modules').textContent).toBe( '2.0.0' ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('svg inclusion', async () => { @@ -133,20 +133,20 @@ describe('Integration', () => { expect(doc.getElementById('feature-svg-inclusion').src).toMatch( /\/static\/media\/logo\..+\.svg$/ ); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('svg component', async () => { const doc = await initDOM('svg-component'); expect(doc.getElementById('feature-svg-component').textContent).toBe(''); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('svg in css', async () => { const doc = await initDOM('svg-in-css'); matchCSS(doc, [/\/static\/media\/logo\..+\.svg/]); - doc.defaultView.close(); + // doc.defaultView.close(); }); it('unknown ext inclusion', async () => { @@ -155,7 +155,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-unknown-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/ ); - doc.defaultView.close(); + // doc.defaultView.close(); }); }); }); From 8da4061ebc75f70ed1c1351da19c4cdfc6177fbd Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 01:53:00 -0700 Subject: [PATCH 17/44] bring back raf --- .../fixtures/kitchensink/.template.dependencies.json | 1 + packages/react-scripts/fixtures/kitchensink/src/index.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index e6add5a4aa8..f1b08a49945 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -5,6 +5,7 @@ "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", + "raf": "3.4.0", "test-integrity": "1.0.0" } } diff --git a/packages/react-scripts/fixtures/kitchensink/src/index.js b/packages/react-scripts/fixtures/kitchensink/src/index.js index 5268eacecf9..a99001633c8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/index.js +++ b/packages/react-scripts/fixtures/kitchensink/src/index.js @@ -5,6 +5,7 @@ * LICENSE file in the root directory of this source tree. */ +import 'raf/polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; From a872f0ca551a8888d824e04c94547ebe06f87612 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 09:32:14 -0700 Subject: [PATCH 18/44] test revert all broken changes --- .../fixtures/kitchensink/integration/initDOM.js | 1 - tasks/e2e-kitchensink.sh | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index e807888d397..900d42b30a4 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -61,7 +61,6 @@ export default feature => created: (_, win) => win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true), deferClose: true, - pretendToBeVisual: true, resourceLoader, url: `${host}#${feature}`, virtualConsole: jsdom.createVirtualConsole().sendTo(console), diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index bda3c3bc069..6a3dda2b5d0 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,7 +151,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -159,7 +159,7 @@ E2E_FILE=./build/index.html \ NODE_ENV=production \ BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --config='jest.integration.config.js' # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -200,7 +200,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ @@ -209,7 +209,7 @@ E2E_FILE=./build/index.html \ BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --config='jest.integration.config.js' # Cleanup cleanup From 7cba08e449fcb2e2936e8b1a4b31b2a33d065f32 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 10:06:04 -0700 Subject: [PATCH 19/44] add back jsdom --- .../fixtures/kitchensink/.template.dependencies.json | 1 + .../fixtures/kitchensink/jest.integration.config.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index f1b08a49945..1524d958098 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -2,6 +2,7 @@ "dependencies": { "bootstrap": "4.1.1", "jest": "23.1.0", + "jsdom": "11.11.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", diff --git a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js index fc778892493..1889333081d 100644 --- a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js +++ b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js @@ -1,4 +1,3 @@ module.exports = { - testEnvironment: 'node', testMatch: ['**/integration/*.test.js'], }; From bed3ec347ddea84720ae0c85069a00aaf31908a6 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 10:46:46 -0700 Subject: [PATCH 20/44] remove jsdom --- .../fixtures/kitchensink/.template.dependencies.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 1524d958098..f1b08a49945 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -2,7 +2,6 @@ "dependencies": { "bootstrap": "4.1.1", "jest": "23.1.0", - "jsdom": "11.11.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", From 511b163a174213425893e96d189690665e1a6d66 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 11:05:26 -0700 Subject: [PATCH 21/44] node test environment --- .../fixtures/kitchensink/.template.dependencies.json | 1 + .../fixtures/kitchensink/jest.integration.config.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index f1b08a49945..1524d958098 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -2,6 +2,7 @@ "dependencies": { "bootstrap": "4.1.1", "jest": "23.1.0", + "jsdom": "11.11.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", diff --git a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js index 1889333081d..fc778892493 100644 --- a/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js +++ b/packages/react-scripts/fixtures/kitchensink/jest.integration.config.js @@ -1,3 +1,4 @@ module.exports = { + testEnvironment: 'node', testMatch: ['**/integration/*.test.js'], }; From 59584c0edd4eeede4c2502324fa0365cfc24128d Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 11:33:02 -0700 Subject: [PATCH 22/44] use latest change --- .../kitchensink/.template.dependencies.json | 2 -- .../kitchensink/integration/env.test.js | 10 +++---- .../kitchensink/integration/initDOM.js | 1 + .../kitchensink/integration/syntax.test.js | 30 +++++++++---------- .../kitchensink/integration/webpack.test.js | 30 +++++++++---------- .../fixtures/kitchensink/src/index.js | 1 - tasks/e2e-kitchensink.sh | 8 ++--- 7 files changed, 40 insertions(+), 42 deletions(-) diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 1524d958098..e6add5a4aa8 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -2,11 +2,9 @@ "dependencies": { "bootstrap": "4.1.1", "jest": "23.1.0", - "jsdom": "11.11.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", - "raf": "3.4.0", "test-integrity": "1.0.0" } } diff --git a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js index 03a28a97a36..79de16706dc 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js @@ -34,14 +34,14 @@ describe('Integration', () => { 'x-from-development-env' ); } - // doc.defaultView.close(); + doc.defaultView.close(); }); it('NODE_PATH', async () => { const doc = await initDOM('node-path'); expect(doc.getElementById('feature-node-path').childElementCount).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('PUBLIC_URL', async () => { @@ -57,7 +57,7 @@ describe('Integration', () => { expect( doc.querySelector('head link[rel="shortcut icon"]').getAttribute('href') ).toBe(`${prefix}/favicon.ico`); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('shell env variables', async () => { @@ -66,7 +66,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-shell-env-variables').textContent ).toBe('fromtheshell.'); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('expand .env variables', async () => { @@ -84,7 +84,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-expand-env-existing').textContent ).toBe('fromtheshell'); - // doc.defaultView.close(); + doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index 900d42b30a4..e807888d397 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -61,6 +61,7 @@ export default feature => created: (_, win) => win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true), deferClose: true, + pretendToBeVisual: true, resourceLoader, url: `${host}#${feature}`, virtualConsole: jsdom.createVirtualConsole().sendTo(console), diff --git a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js index e2011bbefea..54920726fa5 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js @@ -15,7 +15,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-array-destructuring').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('array spread', async () => { @@ -24,7 +24,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-array-spread').childElementCount).toBe( 4 ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('async/await', async () => { @@ -33,7 +33,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-async-await').childElementCount).toBe( 4 ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('class properties', async () => { @@ -42,7 +42,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-class-properties').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('computed properties', async () => { @@ -51,7 +51,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-computed-properties').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('custom interpolation', async () => { @@ -60,7 +60,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-custom-interpolation').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('default parameters', async () => { @@ -69,7 +69,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-default-parameters').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('destructuring and await', async () => { @@ -78,7 +78,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-destructuring-and-await').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('generators', async () => { @@ -87,7 +87,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-generators').childElementCount).toBe( 4 ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('object destructuring', async () => { @@ -96,7 +96,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-destructuring').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('object spread', async () => { @@ -105,14 +105,14 @@ describe('Integration', () => { expect( doc.getElementById('feature-object-spread').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('promises', async () => { const doc = await initDOM('promises'); expect(doc.getElementById('feature-promises').childElementCount).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('rest + default', async () => { @@ -121,7 +121,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-and-default').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('rest parameters', async () => { @@ -130,7 +130,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-rest-parameters').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('template interpolation', async () => { @@ -139,7 +139,7 @@ describe('Integration', () => { expect( doc.getElementById('feature-template-interpolation').childElementCount ).toBe(4); - // doc.defaultView.close(); + doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index f870f640a0c..ebd830dfaaa 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -39,7 +39,7 @@ describe('Integration', () => { /html\{/, /#feature-css-inclusion\{background:.+;color:.+}/, ]); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('css modules inclusion', async () => { @@ -48,13 +48,13 @@ describe('Integration', () => { /.+style_cssModulesInclusion__.+\{background:.+;color:.+}/, /.+assets_cssModulesIndexInclusion__.+\{background:.+;color:.+}/, ]); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('scss inclusion', async () => { const doc = await initDOM('scss-inclusion'); matchCSS(doc, [/#feature-scss-inclusion\{background:.+;color:.+}/]); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('scss modules inclusion', async () => { @@ -63,13 +63,13 @@ describe('Integration', () => { /.+scss-styles_scssModulesInclusion.+\{background:.+;color:.+}/, /.+assets_scssModulesIndexInclusion.+\{background:.+;color:.+}/, ]); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('sass inclusion', async () => { const doc = await initDOM('sass-inclusion'); matchCSS(doc, [/#feature-sass-inclusion\{background:.+;color:.+}/]); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('sass modules inclusion', async () => { @@ -78,7 +78,7 @@ describe('Integration', () => { /.+sass-styles_sassModulesInclusion.+\{background:.+;color:.+}/, /.+assets_sassModulesIndexInclusion.+\{background:.+;color:.+}/, ]); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('graphql files inclusion', async () => { @@ -89,7 +89,7 @@ describe('Integration', () => { expect(children[0].textContent.replace(/\s/g, '')).toBe( '{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}' ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('image inclusion', async () => { @@ -98,7 +98,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-image-inclusion').src).toMatch( /^data:image\/jpeg;base64.+==$/ ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('no ext inclusion', async () => { @@ -107,7 +107,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-no-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithoutExt\.[a-f0-9]{8}\.bin$/ ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('json inclusion', async () => { @@ -116,7 +116,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-json-inclusion').textContent).toBe( 'This is an abstract.' ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('linked modules', async () => { @@ -125,7 +125,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-linked-modules').textContent).toBe( '2.0.0' ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('svg inclusion', async () => { @@ -133,20 +133,20 @@ describe('Integration', () => { expect(doc.getElementById('feature-svg-inclusion').src).toMatch( /\/static\/media\/logo\..+\.svg$/ ); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('svg component', async () => { const doc = await initDOM('svg-component'); expect(doc.getElementById('feature-svg-component').textContent).toBe(''); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('svg in css', async () => { const doc = await initDOM('svg-in-css'); matchCSS(doc, [/\/static\/media\/logo\..+\.svg/]); - // doc.defaultView.close(); + doc.defaultView.close(); }); it('unknown ext inclusion', async () => { @@ -155,7 +155,7 @@ describe('Integration', () => { expect(doc.getElementById('feature-unknown-ext-inclusion').href).toMatch( /\/static\/media\/aFileWithExt\.[a-f0-9]{8}\.unknown$/ ); - // doc.defaultView.close(); + doc.defaultView.close(); }); }); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/index.js b/packages/react-scripts/fixtures/kitchensink/src/index.js index a99001633c8..5268eacecf9 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/index.js +++ b/packages/react-scripts/fixtures/kitchensink/src/index.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import 'raf/polyfill'; import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 6a3dda2b5d0..bda3c3bc069 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,7 +151,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -159,7 +159,7 @@ E2E_FILE=./build/index.html \ NODE_ENV=production \ BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -200,7 +200,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ @@ -209,7 +209,7 @@ E2E_FILE=./build/index.html \ BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --config='jest.integration.config.js' # Cleanup cleanup From 329505432e73477e89c548c63b663e134530d6df Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 12:23:37 -0700 Subject: [PATCH 23/44] runInBand --- tasks/e2e-kitchensink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index bda3c3bc069..d7b5b744e3b 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -200,7 +200,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --runInBand --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ From b5da335ae9646b1fd49e92ce08b9699435b4b959 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 12:40:59 -0700 Subject: [PATCH 24/44] runInBand --- tasks/e2e-kitchensink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index d7b5b744e3b..ced2364bbc2 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,7 +151,7 @@ E2E_URL="http://localhost:3001" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --runInBand --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ From a99d693c4b7a52689ceb603ffecbf9d68a1598a8 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 16:55:18 -0700 Subject: [PATCH 25/44] comment test run --- tasks/e2e-kitchensink.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index ced2364bbc2..c277c0ec8a2 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -146,6 +146,7 @@ PORT=3001 \ grep -q 'You can now view' <(tail -f $tmp_server_log) # Test "development" environment +# Run integration tests sequentially using --runInBand to reduce Travis CI flakiness E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ @@ -189,6 +190,7 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ yarn test --no-cache --testPathPattern=src # Test "development" environment +# Run integration tests sequentially using --runInBand to reduce Travis CI flakiness tmp_server_log=`mktemp` PORT=3002 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ From 7601f1ba86ed761582868eba92581c8c9d421bed Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 20:49:58 -0700 Subject: [PATCH 26/44] try different jest option --- tasks/e2e-kitchensink.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index c277c0ec8a2..67bdd3af4c6 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -146,13 +146,13 @@ PORT=3001 \ grep -q 'You can now view' <(tail -f $tmp_server_log) # Test "development" environment -# Run integration tests sequentially using --runInBand to reduce Travis CI flakiness +# https://facebook.github.io/jest/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-and-or-continuous-integration-ci-server E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --runInBand --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --maxWorkers=4 --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -190,7 +190,6 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ yarn test --no-cache --testPathPattern=src # Test "development" environment -# Run integration tests sequentially using --runInBand to reduce Travis CI flakiness tmp_server_log=`mktemp` PORT=3002 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ @@ -202,7 +201,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --runInBand --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --maxWorkers=4 --no-cache --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ From 42200e33aa2a8a456a796570fda85edc97aa3a2d Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 21:28:00 -0700 Subject: [PATCH 27/44] standardize jest test options --- tasks/e2e-kitchensink.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 67bdd3af4c6..5f185b6c3fd 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -131,11 +131,12 @@ exists build/*.html exists build/static/js/main.*.js # Unit tests +# https://facebook.github.io/jest/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-and-or-continuous-integration-ci-server REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ NODE_ENV=test \ - yarn test --no-cache --testPathPattern=src + yarn test --no-cache --runInBand --testPathPattern=src # Prepare "development" environment tmp_server_log=`mktemp` @@ -146,13 +147,12 @@ PORT=3001 \ grep -q 'You can now view' <(tail -f $tmp_server_log) # Test "development" environment -# https://facebook.github.io/jest/docs/en/troubleshooting.html#tests-are-extremely-slow-on-docker-and-or-continuous-integration-ci-server E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --maxWorkers=4 --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ @@ -160,7 +160,7 @@ E2E_FILE=./build/index.html \ NODE_ENV=production \ BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -187,7 +187,7 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ NODE_ENV=test \ - yarn test --no-cache --testPathPattern=src + yarn test --no-cache --runInBand --testPathPattern=src # Test "development" environment tmp_server_log=`mktemp` @@ -201,7 +201,7 @@ E2E_URL="http://localhost:3002" \ CI=true NODE_PATH=src \ NODE_ENV=development \ BABEL_ENV=test \ - node_modules/.bin/jest --maxWorkers=4 --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' # Test "production" environment E2E_FILE=./build/index.html \ @@ -210,7 +210,7 @@ E2E_FILE=./build/index.html \ BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --no-cache --config='jest.integration.config.js' + node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' # Cleanup cleanup From ff8507de6e5f68f3771a95761c60a9148bc3ac1e Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 22:36:26 -0700 Subject: [PATCH 28/44] increase heap size --- tasks/e2e-kitchensink.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 5f185b6c3fd..890cea2df14 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -124,7 +124,7 @@ npm link "$temp_module_path/node_modules/test-integrity" REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - yarn build + yarn build --max_old_space_size=4096 # Check for expected output exists build/*.html @@ -176,7 +176,7 @@ npm link "$temp_module_path/node_modules/test-integrity" REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - yarn build + yarn build --max_old_space_size=4096 # Check for expected output exists build/*.html From 5c4f644380a5c67a131e4d30c863d62af671422e Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 10 Jun 2018 23:29:37 -0700 Subject: [PATCH 29/44] remove heap size config --- tasks/e2e-kitchensink.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 890cea2df14..5f185b6c3fd 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -124,7 +124,7 @@ npm link "$temp_module_path/node_modules/test-integrity" REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - yarn build --max_old_space_size=4096 + yarn build # Check for expected output exists build/*.html @@ -176,7 +176,7 @@ npm link "$temp_module_path/node_modules/test-integrity" REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ - yarn build --max_old_space_size=4096 + yarn build # Check for expected output exists build/*.html From f554fa91a6f2543344885e55023be4387b4eb9f1 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sun, 24 Jun 2018 15:32:53 -0700 Subject: [PATCH 30/44] support scoped packages for cra --scripts-version option --- packages/create-react-app/createReactApp.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 7645af38872..fbf0f3c8160 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -214,7 +214,9 @@ function createApp(name, verbose, version, useNpm, template) { if (!semver.satisfies(process.version, '>=6.0.0')) { console.log( chalk.yellow( - `You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` + + `You are using Node ${ + process.version + } so the project will be bootstrapped with an old unsupported version of tools.\n\n` + `Please update to Node 6 or higher for a better, fully supported experience.\n` ) ); @@ -228,7 +230,9 @@ function createApp(name, verbose, version, useNpm, template) { if (npmInfo.npmVersion) { console.log( chalk.yellow( - `You are using npm ${npmInfo.npmVersion} so the project will be boostrapped with an old unsupported version of tools.\n\n` + + `You are using npm ${ + npmInfo.npmVersion + } so the project will be boostrapped with an old unsupported version of tools.\n\n` + `Please update to npm 3 or higher for a better, fully supported experience.\n` ) ); @@ -409,7 +413,7 @@ function getInstallPackage(version, originalDirectory) { if (validSemver) { packageToInstall += `@${validSemver}`; } else if (version) { - if (version[0] === '@') { + if (version[0] === '@' && version.indexOf('/') === -1) { packageToInstall += version; } else if (version.match(/^file:/)) { packageToInstall = `file:${path.resolve( From 40834682d24b408848cb126d928bff2534d42f16 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Thu, 5 Jul 2018 20:13:28 -0700 Subject: [PATCH 31/44] upgrade jest version --- packages/confusing-browser-globals/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 4 ++-- .../fixtures/kitchensink/.template.dependencies.json | 2 +- .../fixtures/monorepos/packages/comp1/package.json | 4 ++-- .../fixtures/monorepos/packages/comp2/package.json | 4 ++-- .../fixtures/monorepos/packages/cra-app1/package.json | 4 ++-- packages/react-scripts/package.json | 4 ++-- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/confusing-browser-globals/package.json b/packages/confusing-browser-globals/package.json index 8ac8abcd1db..272da26c48c 100644 --- a/packages/confusing-browser-globals/package.json +++ b/packages/confusing-browser-globals/package.json @@ -16,6 +16,6 @@ "index.js" ], "devDependencies": { - "jest": "23.1.0" + "jest": "23.3.0" } } diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 6407e370825..20e9928986e 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -62,7 +62,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "23.1.0" + "jest": "23.3.0" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index f5182b115a1..7d38c45e9af 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -36,7 +36,7 @@ "anser": "1.4.6", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^8.2.2", - "babel-jest": "^23.0.1", + "babel-jest": "^23.2.0", "babel-loader": "^8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", "chalk": "^2.3.2", @@ -50,7 +50,7 @@ "eslint-plugin-react": "7.8.2", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "23.1.0", + "jest": "23.3.0", "jest-fetch-mock": "1.5.0", "object-assign": "4.1.1", "promise": "8.0.1", diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index e6add5a4aa8..97ebfa485e2 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,7 +1,7 @@ { "dependencies": { "bootstrap": "4.1.1", - "jest": "23.1.0", + "jest": "23.3.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", diff --git a/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json b/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json index ea6b52e65db..e23bbdf2162 100644 --- a/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json +++ b/packages/react-scripts/fixtures/monorepos/packages/comp1/package.json @@ -4,7 +4,7 @@ "main": "index.js", "license": "MIT", "devDependencies": { - "react": "^16.4.0", - "react-dom": "^16.4.0" + "react": "^16.4.1", + "react-dom": "^16.4.1" } } diff --git a/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json b/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json index c905edc726a..5fcb856348f 100644 --- a/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json +++ b/packages/react-scripts/fixtures/monorepos/packages/comp2/package.json @@ -4,8 +4,8 @@ "comp1": "^1.0.0" }, "devDependencies": { - "react": "^16.4.0", - "react-dom": "^16.4.0" + "react": "^16.4.1", + "react-dom": "^16.4.1" }, "version": "1.0.0", "main": "index.js", diff --git a/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json b/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json index 4815ebc873e..ad028c62fd2 100644 --- a/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json +++ b/packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json @@ -4,8 +4,8 @@ "private": true, "dependencies": { "comp2": "^1.0.0", - "react": "^16.4.0", - "react-dom": "^16.4.0" + "react": "^16.4.1", + "react-dom": "^16.4.1" }, "devDependencies": { "react-scripts": "latest" diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 2993611c49b..ecb6f39f971 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -26,7 +26,7 @@ "autoprefixer": "8.5.0", "babel-core": "7.0.0-bridge.0", "babel-eslint": "8.2.3", - "babel-jest": "23.0.1", + "babel-jest": "23.2.0", "babel-loader": "8.0.0-beta.0", "babel-plugin-named-asset-import": "^0.1.0", "babel-preset-react-app": "^3.1.1", @@ -49,7 +49,7 @@ "html-webpack-plugin": "3.2.0", "identity-obj-proxy": "3.0.0", "loader-utils": "^1.1.0", - "jest": "23.1.0", + "jest": "23.3.0", "mini-css-extract-plugin": "^0.4.0", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.3.1", diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index d12bf415b71..e884518d73a 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -44,7 +44,7 @@ module.exports = (resolve, rootDir, srcRoots) => { ), }, transformIgnorePatterns: [ - '/node_modules/.+\\.(js|jsx|mjs)$', + '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$', '^.+\\.module\\.(css|sass|scss)$', ], moduleNameMapper: { From dbbe6915795d075d91b0ec7076c2eb827a367d7c Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Thu, 5 Jul 2018 21:44:26 -0700 Subject: [PATCH 32/44] fix windows --- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index e884518d73a..823470c01c0 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -44,7 +44,7 @@ module.exports = (resolve, rootDir, srcRoots) => { ), }, transformIgnorePatterns: [ - '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$', + '[/\\\\\\\\]node_modules[/\\\\\\\\].+\\.(js|jsx|mjs)$', '^.+\\.module\\.(css|sass|scss)$', ], moduleNameMapper: { From 7ddd29854dfb987dc82778fdbf46dc6c09f4a72d Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Thu, 5 Jul 2018 22:14:40 -0700 Subject: [PATCH 33/44] fix windows again --- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 823470c01c0..d12bf415b71 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -44,7 +44,7 @@ module.exports = (resolve, rootDir, srcRoots) => { ), }, transformIgnorePatterns: [ - '[/\\\\\\\\]node_modules[/\\\\\\\\].+\\.(js|jsx|mjs)$', + '/node_modules/.+\\.(js|jsx|mjs)$', '^.+\\.module\\.(css|sass|scss)$', ], moduleNameMapper: { From e7ecaae6e1d8b058a179c0b5e72330c3715ee1dd Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Fri, 13 Jul 2018 18:35:21 -0700 Subject: [PATCH 34/44] jest 23.4.1 --- packages/confusing-browser-globals/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 4 ++-- .../fixtures/kitchensink/.template.dependencies.json | 2 +- packages/react-scripts/package.json | 4 ++-- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/confusing-browser-globals/package.json b/packages/confusing-browser-globals/package.json index 272da26c48c..b6bd158a4db 100644 --- a/packages/confusing-browser-globals/package.json +++ b/packages/confusing-browser-globals/package.json @@ -16,6 +16,6 @@ "index.js" ], "devDependencies": { - "jest": "23.3.0" + "jest": "23.4.1" } } diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 20e9928986e..1a7802d123c 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -62,7 +62,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "23.3.0" + "jest": "23.4.1" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 7d38c45e9af..03b1f4a8652 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -36,7 +36,7 @@ "anser": "1.4.6", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^8.2.2", - "babel-jest": "^23.2.0", + "babel-jest": "^23.4.1", "babel-loader": "^8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", "chalk": "^2.3.2", @@ -50,7 +50,7 @@ "eslint-plugin-react": "7.8.2", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "23.3.0", + "jest": "23.4.1", "jest-fetch-mock": "1.5.0", "object-assign": "4.1.1", "promise": "8.0.1", diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 97ebfa485e2..1322714f5f1 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,7 +1,7 @@ { "dependencies": { "bootstrap": "4.1.1", - "jest": "23.3.0", + "jest": "23.4.1", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index ecb6f39f971..b7a5d89e574 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -26,7 +26,7 @@ "autoprefixer": "8.5.0", "babel-core": "7.0.0-bridge.0", "babel-eslint": "8.2.3", - "babel-jest": "23.2.0", + "babel-jest": "23.4.0", "babel-loader": "8.0.0-beta.0", "babel-plugin-named-asset-import": "^0.1.0", "babel-preset-react-app": "^3.1.1", @@ -49,7 +49,7 @@ "html-webpack-plugin": "3.2.0", "identity-obj-proxy": "3.0.0", "loader-utils": "^1.1.0", - "jest": "23.3.0", + "jest": "23.4.1", "mini-css-extract-plugin": "^0.4.0", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.3.1", diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index d12bf415b71..e884518d73a 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -44,7 +44,7 @@ module.exports = (resolve, rootDir, srcRoots) => { ), }, transformIgnorePatterns: [ - '/node_modules/.+\\.(js|jsx|mjs)$', + '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$', '^.+\\.module\\.(css|sass|scss)$', ], moduleNameMapper: { From 793e41916facf0ff74c934d2d497b3c513872625 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Fri, 13 Jul 2018 18:57:41 -0700 Subject: [PATCH 35/44] babel-jest --- packages/react-dev-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 1a7802d123c..519cb2ebc8b 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -62,7 +62,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "23.4.1" + "jest": "23.4.0" }, "scripts": { "test": "jest" From 375016464ee8056249186939626ecf91ab36a5d6 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Fri, 13 Jul 2018 19:03:48 -0700 Subject: [PATCH 36/44] babel-jest --- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 519cb2ebc8b..1a7802d123c 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -62,7 +62,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "23.4.0" + "jest": "23.4.1" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 03b1f4a8652..3f5ef7ea16e 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -36,7 +36,7 @@ "anser": "1.4.6", "babel-core": "^7.0.0-bridge.0", "babel-eslint": "^8.2.2", - "babel-jest": "^23.4.1", + "babel-jest": "^23.4.0", "babel-loader": "^8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", "chalk": "^2.3.2", From 08d233d189a05c6f8e1e5029fe6448a7a8791ff3 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 14 Jul 2018 10:39:10 -0700 Subject: [PATCH 37/44] split out kitchhensink --- .travis.yml | 3 + appveyor.yml | 4 + tasks/e2e-kitchensink-eject.sh | 174 +++++++++++++++++++++++++++++++++ tasks/e2e-kitchensink.sh | 50 ---------- 4 files changed, 181 insertions(+), 50 deletions(-) create mode 100755 tasks/e2e-kitchensink-eject.sh diff --git a/.travis.yml b/.travis.yml index f27e0e9a2b8..e2f06e347a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ script: - 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi' - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi' - 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi' + - 'if [ $TEST_SUITE = "kitchensink-eject" ]; then tasks/e2e-kitchensink-eject.sh; fi' - 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi' - 'if [ $TEST_SUITE = "monorepos" ]; then tasks/e2e-monorepos.sh; fi' env: @@ -21,6 +22,7 @@ env: - TEST_SUITE=simple - TEST_SUITE=installs - TEST_SUITE=kitchensink + - TEST_SUITE=kitchensink-eject - TEST_SUITE=monorepos matrix: include: @@ -28,3 +30,4 @@ matrix: env: TEST_SUITE=old-node - node_js: 6 env: TEST_SUITE=kitchensink + env: TEST_SUITE=kitchensink-eject diff --git a/appveyor.yml b/appveyor.yml index db1d640caa1..9cb7b58f8a4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -8,6 +8,8 @@ environment: test_suite: "installs" - nodejs_version: 8 test_suite: "kitchensink" + - nodejs_version: 8 + test_suite: "kitchensink-eject" - nodejs_version: 8 test_suite: "monorepos" - nodejs_version: 6 @@ -16,6 +18,8 @@ environment: test_suite: "installs" - nodejs_version: 6 test_suite: "kitchensink" + - nodejs_version: 6 + test_suite: "kitchensink-eject" - nodejs_version: 6 test_suite: "monorepos" cache: diff --git a/tasks/e2e-kitchensink-eject.sh b/tasks/e2e-kitchensink-eject.sh new file mode 100755 index 00000000000..17dd2111754 --- /dev/null +++ b/tasks/e2e-kitchensink-eject.sh @@ -0,0 +1,174 @@ +#!/bin/bash +# Copyright (c) 2015-present, Facebook, Inc. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. + +# ****************************************************************************** +# This is an end-to-end kitchensink test intended to run on CI. +# You can also run it locally but it's slow. +# ****************************************************************************** + +# Start in tasks/ even if run from root directory +cd "$(dirname "$0")" + +# CLI, app, and test module temporary locations +# http://unix.stackexchange.com/a/84980 +temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'` +temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'` +custom_registry_url=http://localhost:4873 +original_npm_registry_url=`npm get registry` +original_yarn_registry_url=`yarn config get registry` + +function cleanup { + echo 'Cleaning up.' + unset BROWSERSLIST + ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9 + cd "$root_path" + # TODO: fix "Device or resource busy" and remove ``|| $CI` + rm -rf "$temp_app_path" "$temp_module_path" || $CI + npm set registry "$original_npm_registry_url" + yarn config set registry "$original_yarn_registry_url" +} + +# Error messages are redirected to stderr +function handle_error { + echo "$(basename $0): ERROR! An error was encountered executing line $1." 1>&2; + cleanup + echo 'Exiting with error.' 1>&2; + exit 1 +} + +function handle_exit { + cleanup + echo 'Exiting without error.' 1>&2; + exit +} + +# Check for the existence of one or more files. +function exists { + for f in $*; do + test -e "$f" + done +} + +# Exit the script with a helpful error message when any error is encountered +trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR + +# Cleanup before exit on any termination signal +trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP + +# Echo every command being executed +set -x + +# Go to root +cd .. +root_path=$PWD + +if hash npm 2>/dev/null +then + npm i -g npm@latest +fi + +# Bootstrap monorepo +yarn + +# ****************************************************************************** +# First, publish the monorepo. +# ****************************************************************************** + +# Start local registry +tmp_registry_log=`mktemp` +nohup npx verdaccio@2.7.2 -c tasks/verdaccio.yaml &>$tmp_registry_log & +# Wait for `verdaccio` to boot +grep -q 'http address' <(tail -f $tmp_registry_log) + +# Set registry to local registry +npm set registry "$custom_registry_url" +yarn config set registry "$custom_registry_url" + +# Login so we can publish packages +npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes + +# Publish the monorepo +git clean -df +./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest + +# ****************************************************************************** +# Now that we have published them, create a clean app folder and install them. +# ****************************************************************************** + +# Install the app in a temporary location +cd $temp_app_path +npx create-react-app --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink + +# Install the test module +cd "$temp_module_path" +yarn add test-integrity@^2.0.1 + +# ****************************************************************************** +# Now that we used create-react-app to create an app depending on react-scripts, +# let's make sure all npm scripts are in the working state. +# ****************************************************************************** + +# Enter the app directory +cd "$temp_app_path/test-kitchensink" + +# In kitchensink, we want to test all transforms +export BROWSERSLIST='ie 9' + +# Link to test module +npm link "$temp_module_path/node_modules/test-integrity" + +# ****************************************************************************** +# Finally, let's check that everything still works after ejecting. +# ****************************************************************************** + +# Eject... +echo yes | npm run eject + +# Link to test module +npm link "$temp_module_path/node_modules/test-integrity" + +# Test the build +REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ + NODE_PATH=src \ + PUBLIC_URL=http://www.example.org/spa/ \ + yarn build + +# Check for expected output +exists build/*.html +exists build/static/js/main.*.js + +# Unit tests +REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ + CI=true \ + NODE_PATH=src \ + NODE_ENV=test \ + yarn test --no-cache --runInBand --testPathPattern=src + +# Test "development" environment +tmp_server_log=`mktemp` +PORT=3002 \ + REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ + NODE_PATH=src \ + nohup yarn start &>$tmp_server_log & +grep -q 'You can now view' <(tail -f $tmp_server_log) +E2E_URL="http://localhost:3002" \ + REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ + CI=true NODE_PATH=src \ + NODE_ENV=development \ + BABEL_ENV=test \ + node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' + +# Test "production" environment +E2E_FILE=./build/index.html \ + CI=true \ + NODE_ENV=production \ + BABEL_ENV=test \ + NODE_PATH=src \ + PUBLIC_URL=http://www.example.org/spa/ \ + node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' + +# Cleanup +cleanup diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 5f185b6c3fd..d12fb4824b4 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -162,55 +162,5 @@ E2E_FILE=./build/index.html \ PUBLIC_URL=http://www.example.org/spa/ \ node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' -# ****************************************************************************** -# Finally, let's check that everything still works after ejecting. -# ****************************************************************************** - -# Eject... -echo yes | npm run eject - -# Link to test module -npm link "$temp_module_path/node_modules/test-integrity" - -# Test the build -REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ - NODE_PATH=src \ - PUBLIC_URL=http://www.example.org/spa/ \ - yarn build - -# Check for expected output -exists build/*.html -exists build/static/js/main.*.js - -# Unit tests -REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ - CI=true \ - NODE_PATH=src \ - NODE_ENV=test \ - yarn test --no-cache --runInBand --testPathPattern=src - -# Test "development" environment -tmp_server_log=`mktemp` -PORT=3002 \ - REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ - NODE_PATH=src \ - nohup yarn start &>$tmp_server_log & -grep -q 'You can now view' <(tail -f $tmp_server_log) -E2E_URL="http://localhost:3002" \ - REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ - CI=true NODE_PATH=src \ - NODE_ENV=development \ - BABEL_ENV=test \ - node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' - -# Test "production" environment -E2E_FILE=./build/index.html \ - CI=true \ - NODE_ENV=production \ - BABEL_ENV=test \ - NODE_PATH=src \ - PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/jest --no-cache --runInBand --config='jest.integration.config.js' - # Cleanup cleanup From 9ced58ce8b8007c71dd4b38dfe61944e93423bd9 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 14 Jul 2018 10:44:35 -0700 Subject: [PATCH 38/44] travis node 6 --- .travis.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e2f06e347a5..bde48489251 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,5 +29,7 @@ matrix: - node_js: 0.10 env: TEST_SUITE=old-node - node_js: 6 - env: TEST_SUITE=kitchensink - env: TEST_SUITE=kitchensink-eject + env: + matrix: + - TEST_SUITE=kitchensink + - TEST_SUITE=kitchensink-eject From 0f9347d2a21fbdc62ea3beeac45a66e1282d9336 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 14 Jul 2018 11:00:27 -0700 Subject: [PATCH 39/44] travis node 6 config --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index bde48489251..b78685365d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,6 +30,5 @@ matrix: env: TEST_SUITE=old-node - node_js: 6 env: - matrix: - - TEST_SUITE=kitchensink - - TEST_SUITE=kitchensink-eject + - TEST_SUITE=kitchensink + - TEST_SUITE=kitchensink-eject From b33442a0878754f04bd90fd4347933a29274fbd9 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Sat, 14 Jul 2018 11:29:04 -0700 Subject: [PATCH 40/44] node 6 travis eject --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b78685365d1..6dbea3e4ee5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,6 @@ matrix: - node_js: 0.10 env: TEST_SUITE=old-node - node_js: 6 - env: - - TEST_SUITE=kitchensink - - TEST_SUITE=kitchensink-eject + env: TEST_SUITE=kitchensink + - node_js: 6 + env: TEST_SUITE=kitchensink-eject From 51568d6f805378ee58311017b43e8e894fe5f1e1 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Mon, 16 Jul 2018 20:27:46 -0700 Subject: [PATCH 41/44] cache yarn --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index f27e0e9a2b8..4dfabf3481e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ node_js: - 8 - 9 cache: + yarn: true directories: - node_modules - packages/create-react-app/node_modules From d63790dcee48b994550a7ae6c57fa1a013e32018 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Mon, 16 Jul 2018 20:36:58 -0700 Subject: [PATCH 42/44] only cache yarn --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4dfabf3481e..6fc01a0afec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,7 @@ language: node_js node_js: - 8 - 9 -cache: - yarn: true - directories: - - node_modules - - packages/create-react-app/node_modules - - packages/react-scripts/node_modules +cache: yarn install: true script: - 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi' From 3fea1cdc905397c71a4b4e70163d6b933a5f16c9 Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Thu, 20 Sep 2018 21:32:21 -0700 Subject: [PATCH 43/44] remove unrelated changes --- .travis.yml | 6 +++++- .../fixtures/kitchensink/.template.dependencies.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 330f671e2f3..73c08c2d454 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,11 @@ language: node_js node_js: - 8 - 10 -cache: yarn +cache: + directories: + - node_modules + - packages/creact-react-app/node_modules + - packages/react-scripts/node_modules before_install: - curl -o- -L https://yarnpkg.com/install.sh | bash - export PATH="$HOME/.yarn/bin:$PATH" diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 1322714f5f1..e45cf8218e1 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,7 +1,7 @@ { "dependencies": { "bootstrap": "4.1.1", - "jest": "23.4.1", + "jest": "23.6.0", "node-sass": "4.8.3", "normalize.css": "7.0.0", "prop-types": "15.5.6", From 6c1c10e2b589736eff704aa366f08da63d9bcf9b Mon Sep 17 00:00:00 2001 From: Jack Zhao Date: Thu, 20 Sep 2018 21:33:09 -0700 Subject: [PATCH 44/44] typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 73c08c2d454..aea00ad24ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ node_js: cache: directories: - node_modules - - packages/creact-react-app/node_modules + - packages/create-react-app/node_modules - packages/react-scripts/node_modules before_install: - curl -o- -L https://yarnpkg.com/install.sh | bash