Skip to content

Commit f43252a

Browse files
committed
Switch integration tests from jest to mocha
1 parent 101e3e2 commit f43252a

File tree

7 files changed

+70
-71
lines changed

7 files changed

+70
-71
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["latest"]
3+
}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"dependencies": {
3-
"jsdom": "9.8.3"
3+
"babel-preset-latest": "6.16.0",
4+
"babel-register": "6.18.0",
5+
"babel-polyfill": "6.20.0",
6+
"chai": "3.5.0",
7+
"jsdom": "9.8.3",
8+
"mocha": "3.2.0"
49
}
510
}
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1+
import { expect } from 'chai'
12
import initDOM from './initDOM'
23

3-
// eslint-disable-next-line no-undef
4-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000
5-
64
describe('Integration', () => {
75
describe('Environment variables', () => {
86
it('NODE_PATH', async () => {
97
const doc = await initDOM('node-path')
108

11-
expect(doc.getElementById('feature-node-path').childElementCount).toBe(4)
9+
expect(doc.getElementById('feature-node-path').childElementCount).to.equal(4)
1210
})
1311

1412
it('shell env variables', async () => {
1513
const doc = await initDOM('shell-env-variables')
1614

17-
expect(doc.getElementById('feature-shell-env-variables').textContent).toBe('fromtheshell.')
15+
expect(doc.getElementById('feature-shell-env-variables').textContent).to.equal('fromtheshell.')
1816
})
1917

2018
it('file env variables', async () => {
2119
const doc = await initDOM('file-env-variables')
2220

23-
expect(doc.getElementById('feature-file-env-variables').textContent).toBe('fromtheenvfile.')
21+
expect(doc.getElementById('feature-file-env-variables').textContent).to.equal('fromtheenvfile.')
2422
})
2523
})
2624
})

packages/react-scripts/templates/kitchensink/integration/syntax.2.test.js

Lines changed: 0 additions & 38 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,96 @@
1+
import { expect } from 'chai'
12
import initDOM from './initDOM'
23

3-
// eslint-disable-next-line no-undef
4-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000
5-
64
describe('Integration', () => {
75
describe('Language syntax', () => {
86
it('array destructuring', async () => {
97
const doc = await initDOM('array-destructuring')
108

11-
expect(doc.getElementById('feature-array-destructuring').childElementCount).toBe(4)
9+
expect(doc.getElementById('feature-array-destructuring').childElementCount).to.equal(4)
1210
})
1311

1412
it('array spread', async () => {
1513
const doc = await initDOM('array-spread')
1614

17-
expect(doc.getElementById('feature-array-spread').childElementCount).toBe(4)
15+
expect(doc.getElementById('feature-array-spread').childElementCount).to.equal(4)
1816
})
1917

2018
it('async/await', async () => {
2119
const doc = await initDOM('async-await')
2220

23-
expect(doc.getElementById('feature-async-await').childElementCount).toBe(4)
21+
expect(doc.getElementById('feature-async-await').childElementCount).to.equal(4)
2422
})
2523

2624
it('class properties', async () => {
2725
const doc = await initDOM('class-properties')
2826

29-
expect(doc.getElementById('feature-class-properties').childElementCount).toBe(4)
27+
expect(doc.getElementById('feature-class-properties').childElementCount).to.equal(4)
3028
})
3129

3230
it('computed properties', async () => {
3331
const doc = await initDOM('computed-properties')
3432

35-
expect(doc.getElementById('feature-computed-properties').childElementCount).toBe(4)
33+
expect(doc.getElementById('feature-computed-properties').childElementCount).to.equal(4)
3634
})
3735

3836
it('custom interpolation', async () => {
3937
const doc = await initDOM('custom-interpolation')
4038

41-
expect(doc.getElementById('feature-custom-interpolation').childElementCount).toBe(4)
39+
expect(doc.getElementById('feature-custom-interpolation').childElementCount).to.equal(4)
4240
})
4341

4442
it('default parameters', async () => {
4543
const doc = await initDOM('default-parameters')
4644

47-
expect(doc.getElementById('feature-default-parameters').childElementCount).toBe(4)
45+
expect(doc.getElementById('feature-default-parameters').childElementCount).to.equal(4)
4846
})
4947

5048
it('destructuring and await', async () => {
5149
const doc = await initDOM('destructuring-and-await')
5250

53-
expect(doc.getElementById('feature-destructuring-and-await').childElementCount).toBe(4)
51+
expect(doc.getElementById('feature-destructuring-and-await').childElementCount).to.equal(4)
5452
})
5553

5654
it('generators', async () => {
5755
const doc = await initDOM('generators')
5856

59-
expect(doc.getElementById('feature-generators').childElementCount).toBe(4)
57+
expect(doc.getElementById('feature-generators').childElementCount).to.equal(4)
6058
})
6159

6260
it('object destructuring', async () => {
6361
const doc = await initDOM('object-destructuring')
6462

65-
expect(doc.getElementById('feature-object-destructuring').childElementCount).toBe(4)
63+
expect(doc.getElementById('feature-object-destructuring').childElementCount).to.equal(4)
64+
})
65+
66+
it('object spread', async () => {
67+
const doc = await initDOM('object-spread')
68+
69+
expect(doc.getElementById('feature-object-spread').childElementCount).to.equal(4)
70+
})
71+
72+
it('promises', async () => {
73+
const doc = await initDOM('promises')
74+
75+
expect(doc.getElementById('feature-promises').childElementCount).to.equal(4)
76+
})
77+
78+
it('rest + default', async () => {
79+
const doc = await initDOM('rest-and-default')
80+
81+
expect(doc.getElementById('feature-rest-and-default').childElementCount).to.equal(4)
82+
})
83+
84+
it('rest parameters', async () => {
85+
const doc = await initDOM('rest-parameters')
86+
87+
expect(doc.getElementById('feature-rest-parameters').childElementCount).to.equal(4)
88+
})
89+
90+
it('template interpolation', async () => {
91+
const doc = await initDOM('template-interpolation')
92+
93+
expect(doc.getElementById('feature-template-interpolation').childElementCount).to.equal(4)
6694
})
6795
})
6896
})
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,44 @@
1+
import { expect } from 'chai'
12
import initDOM from './initDOM'
23

3-
// eslint-disable-next-line no-undef
4-
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000
5-
64
describe('Integration', () => {
75
describe('Webpack plugins', () => {
86
it('css inclusion', async () => {
97
const doc = await initDOM('css-inclusion')
108

119
expect(doc.getElementsByTagName('style')[0].textContent.replace(/\s/g, ''))
12-
.toMatch(/#feature-css-inclusion\{background:.+;color:.+}/)
10+
.to.match(/#feature-css-inclusion\{background:.+;color:.+}/)
1311
})
1412

1513
it('image inclusion', async () => {
1614
const doc = await initDOM('image-inclusion')
1715

18-
expect(doc.getElementById('feature-image-inclusion').src).toMatch(/^data:image\/jpeg;base64.+==$/)
16+
expect(doc.getElementById('feature-image-inclusion').src).to.match(/^data:image\/jpeg;base64.+==$/)
1917
})
2018

2119
it('no ext inclusion', async () => {
2220
const doc = await initDOM('no-ext-inclusion')
2321

2422
expect(doc.getElementById('feature-no-ext-inclusion').textContent)
25-
.toBe('This is just a file without an extension.')
23+
.to.equal('This is just a file without an extension.')
2624
})
2725

2826
it('json inclusion', async () => {
2927
const doc = await initDOM('json-inclusion')
3028

31-
expect(doc.getElementById('feature-json-inclusion').textContent).toBe('This is an abstract.')
29+
expect(doc.getElementById('feature-json-inclusion').textContent).to.equal('This is an abstract.')
3230
})
3331

3432
it('svg inclusion', async () => {
3533
const doc = await initDOM('svg-inclusion')
3634

37-
expect(doc.getElementById('feature-svg-inclusion').src).toMatch(/\/static\/media\/logo\..+\.svg$/)
35+
expect(doc.getElementById('feature-svg-inclusion').src).to.match(/\/static\/media\/logo\..+\.svg$/)
3836
})
3937

4038
it('unknown ext inclusion', async () => {
4139
const doc = await initDOM('unknown-ext-inclusion')
4240

43-
expect(doc.getElementById('feature-unknown-ext-inclusion').textContent).toBe('Whoooo, spooky!.')
41+
expect(doc.getElementById('feature-unknown-ext-inclusion').textContent).to.equal('Whoooo, spooky!.')
4442
})
4543
})
4644
})

tasks/e2e.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ grep -q 'The app is running at:' <(tail -f $tmp_server_log)
170170
E2E_URL="http://localhost:3001" \
171171
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
172172
CI=true NODE_PATH=src \
173-
npm test -- --no-cache --testPathPattern="/integration/"
173+
node node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js
174174

175175
# Test "production" environment
176176
E2E_FILE=./build/index.html \
177177
CI=true \
178178
NODE_PATH=src \
179-
npm test -- --no-cache --testPathPattern="/integration/"
179+
node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.js
180180

181181
# Uncomment when snapshot testing is enabled by default:
182182
# test -e src/__snapshots__/App.test.js.snap
@@ -197,6 +197,9 @@ npm link $root_path/packages/eslint-config-react-app
197197
npm link $root_path/packages/react-dev-utils
198198
npm link $root_path/packages/react-scripts
199199

200+
# ...and we need to remove template's .babelrc
201+
rm .babelrc
202+
200203
# Test the build
201204
NODE_PATH=src REACT_APP_SHELL_ENV_MESSAGE=fromtheshell npm run build
202205
# Check for expected output
@@ -219,13 +222,15 @@ grep -q 'The app is running at:' <(tail -f $tmp_server_log)
219222
E2E_URL="http://localhost:3002" \
220223
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
221224
CI=true NODE_PATH=src \
222-
npm test -- --no-cache --testPathPattern="/integration/"
225+
NODE_ENV=production \
226+
node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.js
223227

224228
# Test "production" environment
225229
E2E_FILE=./build/index.html \
226230
CI=true \
231+
NODE_ENV=production \
227232
NODE_PATH=src \
228-
npm test -- --no-cache --testPathPattern="/integration/"
233+
node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.js
229234

230235
# Uncomment when snapshot testing is enabled by default:
231236
# test -e src/__snapshots__/App.test.js.snap

0 commit comments

Comments
 (0)