Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest 23 and tests #4550

Merged
merged 51 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
27985a2
convert mocha tests to jest
Jun 2, 2018
a53f4fb
jest 23
Jun 2, 2018
4408910
add jest configs
Jun 2, 2018
08c7b6b
use material css
Jun 3, 2018
c9e1e75
fix windows
Jun 3, 2018
c445b93
forceExit jest test
Jun 3, 2018
411e016
force exit eject
Jun 4, 2018
737ba13
test
Jun 4, 2018
236c779
Merge pull request #2 from facebook/next
Jun 4, 2018
152d059
test
Jun 4, 2018
230931f
retrigger test
Jun 10, 2018
9d6e0cf
remove appveyor comment
Jun 10, 2018
bd6bc73
try to remove pretendToBeVisual option
Jun 10, 2018
d27b1c1
use jsdom env
Jun 10, 2018
a3b37ef
test environment
Jun 10, 2018
987df9e
no cache
Jun 10, 2018
3f881c6
test no close
Jun 10, 2018
8da4061
bring back raf
Jun 10, 2018
a872f0c
test revert all broken changes
Jun 10, 2018
7cba08e
add back jsdom
Jun 10, 2018
bed3ec3
remove jsdom
Jun 10, 2018
511b163
node test environment
Jun 10, 2018
59584c0
use latest change
Jun 10, 2018
3295054
runInBand
Jun 10, 2018
b5da335
runInBand
Jun 10, 2018
a99d693
comment test run
Jun 10, 2018
7601f1b
try different jest option
Jun 11, 2018
42200e3
standardize jest test options
Jun 11, 2018
ff8507d
increase heap size
Jun 11, 2018
5c4f644
remove heap size config
Jun 11, 2018
0acaa44
Merge pull request #3 from facebook/next
Jun 24, 2018
f554fa9
support scoped packages for cra --scripts-version option
Jun 24, 2018
90d5f0b
Merge pull request #4 from facebook/next
Jun 30, 2018
4083468
upgrade jest version
Jul 6, 2018
dbbe691
fix windows
Jul 6, 2018
7ddd298
fix windows again
Jul 6, 2018
e7ecaae
jest 23.4.1
Jul 14, 2018
793e419
babel-jest
Jul 14, 2018
3750164
babel-jest
Jul 14, 2018
08d233d
split out kitchhensink
Jul 14, 2018
9ced58c
travis node 6
Jul 14, 2018
0f9347d
travis node 6 config
Jul 14, 2018
b33442a
node 6 travis eject
Jul 14, 2018
51568d6
cache yarn
Jul 17, 2018
d63790d
only cache yarn
Jul 17, 2018
123a75e
Merge pull request #6 from facebook/next
Jul 17, 2018
fd126ae
Merge branch 'yarn-cache' into next
Jul 17, 2018
9c568a6
Merge pull request #8 from facebook/next
Sep 21, 2018
31ae6af
Merge branch 'next' into jest
Sep 21, 2018
3fea1cd
remove unrelated changes
Sep 21, 2018
6c1c10e
typo
Sep 21, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"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",
"mocha": "3.2.0",
"bootstrap": "4.1.1",
"jest": "23.6.0",
"node-sass": "4.8.3",
"normalize.css": "7.0.0",
"prop-types": "15.5.6",
Expand Down
1 change: 0 additions & 1 deletion packages/react-scripts/fixtures/kitchensink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,3 @@ An usual flow for the test itself is something similar to:

- since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly

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`.
31 changes: 14 additions & 17 deletions packages/react-scripts/fixtures/kitchensink/integration/env.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import { expect } from 'chai';
import initDOM from './initDOM';

describe('Integration', () => {
Expand All @@ -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'
);
}
Expand All @@ -41,9 +40,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);
doc.defaultView.close();
});

Expand All @@ -54,12 +51,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`);
doc.defaultView.close();
});

Expand All @@ -68,25 +65,25 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-shell-env-variables').textContent
).to.equal('fromtheshell.');
).toBe('fromtheshell.');
doc.defaultView.close();
});

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');
doc.defaultView.close();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.be.undefined();
).toBeUndefined();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import { expect } from 'chai';
import initDOM from './initDOM';

describe('Integration', () => {
Expand All @@ -15,25 +14,25 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-array-destructuring').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

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
);
doc.defaultView.close();
});

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
);
doc.defaultView.close();
});

Expand All @@ -42,7 +41,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-class-properties').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

Expand All @@ -51,7 +50,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-computed-properties').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

Expand All @@ -60,7 +59,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-custom-interpolation').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

Expand All @@ -69,7 +68,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-default-parameters').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

Expand All @@ -78,16 +77,16 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-destructuring-and-await').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

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
);
doc.defaultView.close();
});

Expand All @@ -96,7 +95,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-object-destructuring').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

Expand All @@ -105,16 +104,14 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-object-spread').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

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);
doc.defaultView.close();
});

Expand All @@ -123,7 +120,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-rest-and-default').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

Expand All @@ -132,7 +129,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-rest-parameters').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});

Expand All @@ -141,7 +138,7 @@ describe('Integration', () => {

expect(
doc.getElementById('feature-template-interpolation').childElementCount
).to.equal(4);
).toBe(4);
doc.defaultView.close();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import { expect } from 'chai';
import initDOM, { resourceLoader } from './initDOM';
import url from 'url';

Expand All @@ -20,14 +19,14 @@ const matchCSS = (doc, regexes) => {
}
resourceLoader({ url: url.parse(href) }, (_, textContent) => {
for (const regex of regexes) {
expect(textContent).to.match(regex);
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]);
).toMatch(regexes[i]);
}
}
};
Expand Down Expand Up @@ -87,7 +86,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}}}}'
);
doc.defaultView.close();
Expand All @@ -96,7 +95,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.+==$/
);
doc.defaultView.close();
Expand All @@ -105,7 +104,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$/
);
doc.defaultView.close();
Expand All @@ -114,7 +113,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.'
);
doc.defaultView.close();
Expand All @@ -123,15 +122,15 @@ 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'
);
doc.defaultView.close();
});

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$/
);
doc.defaultView.close();
Expand All @@ -140,9 +139,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('');
doc.defaultView.close();
});

Expand All @@ -155,7 +152,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$/
);
doc.defaultView.close();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
testEnvironment: 'node',
testMatch: ['**/integration/*.test.js'],
};
Loading