Skip to content

Commit f575eea

Browse files
authored
Merge pull request #82 from rackerlabs/auto-generate-regression-tests-squashed
test(regression): Add auto-generated "data-visreg" tests
2 parents 632c958 + b5eb3ad commit f575eea

19 files changed

+359
-159
lines changed

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
sudo: false
2+
dist: trusty
3+
language: node_js
4+
node_js:
5+
- '8'
6+
addons:
7+
firefox: '54.0'
8+
chrome: stable
9+
branch:
10+
only:
11+
- master
12+
install:
13+
- npm i -g yarn
14+
- travis_retry yarn install
15+
before_script:
16+
- export DISPLAY=:99.0
17+
- sh -e /etc/init.d/xvfb start
18+
- jdk_switcher use oraclejdk8
19+
- yarn start > /dev/null 2>&1 &
20+
- sleep 5
21+
script:
22+
- yarn test

_config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ CONFIG.root = path.resolve(__dirname);// absolute path to project directory
1717
CONFIG.publicDir = 'public';
1818
CONFIG.sourceDir = 'source';
1919
CONFIG.templateDir = `${CONFIG.sourceDir}/_templates`;
20+
CONFIG.testDir = 'test';
2021

2122
// Component Explorer configuration
2223
// Used directly for "site" rendering context

bin/start.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env node
22
'use strict';
33

4+
const exec = require('child_process').exec;
5+
46
const Build = require('./build');
57
const CONFIG = require('../_config');
68
const Clean = require('./clean');
@@ -16,17 +18,46 @@ Build.buildSync();
1618
const serverRoutes = {}
1719
serverRoutes[CONFIG.site.baseHref] = CONFIG.publicDir;
1820

21+
browserSync.emitter.on('init', () => {
22+
console.log('Starting a selenium webdriver instance...');
23+
exec('yarn run webdriver:start', { cwd: CONFIG.testDir }); // don't log anything to the dev server
24+
});
25+
1926
browserSync.init({
2027
files: [ // (See 'watchEvents')
2128
// Reload browser if any file in public directory changes
2229
`${CONFIG.publicDir}/**/*`,
30+
2331
// Rebuild if anything changes in source directory
2432
{
2533
match: [
2634
`${CONFIG.sourceDir}/**/*`
2735
],
28-
fn: (evt, file) => {
36+
fn: () => {
2937
Build.buildSync();
38+
39+
/**
40+
* Always ensure that this task runs last, as it needs to wait for all
41+
* synchronous build events to complete so that browserSync can finish
42+
* and reload the page (and therefore, allow selenium to connnect).
43+
*/
44+
const tests = exec('yarn run test:regression -- -u', { cwd: CONFIG.testDir });
45+
// this *is* asynchronous, see comment above
46+
tests.stdout.pipe(process.stdout);
47+
tests.stderr.pipe(process.stderr);
48+
}
49+
},
50+
51+
// Re-transpile test files
52+
{
53+
match: [
54+
`${CONFIG.testDir}/**/*.ts`,
55+
`!${CONFIG.testDir}/built/**/*`
56+
],
57+
fn: () => {
58+
const tsc = exec('yarn run build', { cwd: CONFIG.testDir });
59+
tsc.stdout.pipe(process.stdout);
60+
tsc.stderr.pipe(process.stderr);
3061
}
3162
},
3263
],

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@
3131
"build": "bin/build.js",
3232
"clean": "rm -fr node_modules",
3333
"deploy": "bin/deploy.js",
34+
"postinstall": "cd test; yarn install; yarn run webdriver:update; cd -;",
3435
"publish": "bin/publish.js",
3536
"start": "bin/start.js",
36-
"test": "echo \"Error: no test specified\" && exit 1"
37+
"test": "cd test; yarn test"
3738
},
3839
"repository": "git+https://github.com/rackerlabs/helix-ui.git",
3940
"author": "Rackspace",

test/.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.github-token
22
bin/visreg.config.ts
33
built/*
4-
!built/functional/
5-
built/functional/*
6-
!built/functional/*.js.snap
7-
!built/functional/*.js.md
4+
!built/{functional,regression}/
5+
built/{functional,regression}/*
6+
!built/{functional,regression}/*.js.snap
7+
!built/{functional,regression}/*.js.md
88
screenshots

test/built/functional/button.js.md

Lines changed: 0 additions & 38 deletions
This file was deleted.
-370 Bytes
Binary file not shown.

test/built/functional/checkbox.js.md

Lines changed: 0 additions & 47 deletions
This file was deleted.
-434 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)