Skip to content

Commit ffb9eed

Browse files
authored
Integration testing (codesandbox#251)
* Integration tests * Test HTML and make screenshot treshold looser * Remove html * Remove obsolete snapshots * Adjust threshold to 3%
1 parent 79e425b commit ffb9eed

File tree

17 files changed

+458
-33
lines changed

17 files changed

+458
-33
lines changed

.circleci/config.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: 2
2+
3+
jobs:
4+
build:
5+
working_directory: ~/codesandbox-client
6+
docker:
7+
- image: circleci/node:8.4.0
8+
environment:
9+
TZ: "/usr/share/zoneinfo/Europe/Amsterdam"
10+
steps:
11+
- checkout
12+
- restore_cache:
13+
key: dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
14+
- run:
15+
name: Install Dependency
16+
command: yarn install
17+
- save_cache:
18+
key: dependency-cache-{{ .Branch }}-{{ checksum "yarn.lock" }}
19+
paths:
20+
- ./node_modules
21+
- ~/.yarn-cache
22+
- run:
23+
name: Workaround for https://github.com/GoogleChrome/puppeteer/issues/290
24+
command: sh ./integration-tests/scripts/workaround-puppeteer-issue-290.sh
25+
- run:
26+
name: Start Server
27+
command: yarn start:test
28+
background: true
29+
- run:
30+
name: Test
31+
command: |
32+
sleep 2
33+
yarn test:integrations -- --maxWorkers=2
34+
- store_artifacts:
35+
path: integration-tests/tests/__image_snapshots__/__diff_output__
36+
destination: image_snapshot_diff

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# dependencies
44
/node_modules
55

6+
/integration-tests/**/__diff_output__
7+
68
# testing
79
coverage
810

config/webpack.common.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,32 @@ const babelProd = require('./babel.prod');
1414
const NODE_ENV = JSON.parse(env['process.env.NODE_ENV']);
1515
const __DEV__ = NODE_ENV === 'development'; // eslint-disable-line no-underscore-dangle
1616
const __PROD__ = NODE_ENV === 'production'; // eslint-disable-line no-underscore-dangle
17+
const __TEST__ = NODE_ENV === 'test'; // eslint-disable-line no-underscore-dangle
1718
const babelConfig = __DEV__ ? babelDev : babelProd;
1819

1920
module.exports = {
20-
entry: {
21-
app: [require.resolve('./polyfills'), path.join(paths.appSrc, 'index.js')],
22-
sandbox: [
23-
require.resolve('./polyfills'),
24-
path.join(paths.sandboxSrc, 'index.js'),
25-
],
26-
embed: [
27-
require.resolve('./polyfills'),
28-
path.join(paths.embedSrc, 'index.js'),
29-
],
30-
vendor: ['react', 'react-dom', 'styled-components'],
31-
},
21+
entry: __TEST__
22+
? {
23+
sandbox: [
24+
require.resolve('./polyfills'),
25+
path.join(paths.sandboxSrc, 'index.js'),
26+
],
27+
}
28+
: {
29+
app: [
30+
require.resolve('./polyfills'),
31+
path.join(paths.appSrc, 'index.js'),
32+
],
33+
sandbox: [
34+
require.resolve('./polyfills'),
35+
path.join(paths.sandboxSrc, 'index.js'),
36+
],
37+
embed: [
38+
require.resolve('./polyfills'),
39+
path.join(paths.embedSrc, 'index.js'),
40+
],
41+
vendor: ['react', 'react-dom', 'styled-components'],
42+
},
3243
target: 'web',
3344
node: {
3445
fs: 'empty',

integration-tests/jest.config.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rootDir": "../",
3+
"setupTestFrameworkScriptFile": "<rootDir>/integration-tests/setup.js",
4+
"roots": ["integration-tests"]
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
# Workaround for https://github.com/GoogleChrome/puppeteer/issues/290
3+
4+
sudo apt-get update
5+
sudo apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
6+
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
7+
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
8+
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
9+
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget

integration-tests/setup.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { toMatchImageSnapshot } from 'jest-image-snapshot';
2+
3+
expect.extend({ toMatchImageSnapshot });
20.6 KB
Loading
15.4 KB
Loading
67.8 KB
Loading
15.4 KB
Loading

0 commit comments

Comments
 (0)