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 3d0eb7a1c9c..b27b5b77cf1 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -9,7 +9,6 @@ const fs = require('fs'); const http = require('http'); const jsdom = require('jsdom'); const path = require('path'); -const { expect } = require('chai'); let getMarkup; let resourceLoader; @@ -52,7 +51,7 @@ if (process.env.E2E_FILE) { () => { expect( new Error("This isn't the error you are looking for.") - ).to.be.undefined(); + ).toBeUndefined(); } ); } 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 1fe5c9f64cd..0412d5bbfe8 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.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,16 +14,16 @@ describe('Integration', () => { expect( doc.getElementsByTagName('style')[0].textContent.replace(/\s/g, '') - ).to.match(/html\{/); + ).toMatch(/html\{/); expect( doc.getElementsByTagName('style')[1].textContent.replace(/\s/g, '') - ).to.match(/#feature-css-inclusion\{background:.+;color:.+}/); + ).toMatch(/#feature-css-inclusion\{background:.+;color:.+}/); }); 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.+==$/ ); }); @@ -32,7 +31,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$/ ); }); @@ -40,7 +39,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.' ); }); @@ -48,7 +47,7 @@ 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' ); }); @@ -56,7 +55,7 @@ describe('Integration', () => { 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$/ ); }); @@ -64,7 +63,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/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 547821b652a..ffef78f87ae 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -223,15 +223,17 @@ E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js + BABEL_ENV=test \ + node_modules/.bin/jest "integration(/|\\)*.test.*" # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_PATH=src \ NODE_ENV=production \ + BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js + node_modules/.bin/jest "integration(/|\\)*.test.*" # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -285,15 +287,17 @@ E2E_URL="http://localhost:3002" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js + BABEL_ENV=test \ + node_modules/.bin/jest "integration(/|\\)*.test.*" # 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/mocha --require babel-register --require babel-polyfill integration/*.test.js + node_modules/.bin/jest "integration(/|\\)*.test.*" # Cleanup cleanup