Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
feat(pkg): add test framework
Browse files Browse the repository at this point in the history
  • Loading branch information
cdaringe committed Mar 8, 2017
1 parent cffa7a4 commit 7a67a94
Show file tree
Hide file tree
Showing 8 changed files with 446 additions and 65 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ storybook-static
lib
suir.stories.js
styleguide
backstop_data/*
!backstop_data/bitmaps_reference
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
"program": "${workspaceRoot}/scripts/build.js",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "launch",
"name": "Test",
"program": "${workspaceRoot}/scripts/test.js",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "attach",
Expand Down
38 changes: 38 additions & 0 deletions backstop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"id": "prod_test",
"viewports": [
{
"name": "tablet_h",
"width": 1024,
"height": 768
}
],
"debug": true,
"scenarios": [
{
"label": "Octagon",
"url": "http://localhost:3333",
"hideSelectors": [],
"removeSelectors": [],
"selectorExpansion": true,
"selectors": [
".rsg--Playground--preview"
],
"readyEvent": null,
"delay": 5000,
"misMatchThreshold" : 0.1,
"onBeforeScript": "onBefore.js",
"onReadyScript": "onReady.js"
}
],
"paths": {
"bitmaps_reference": "backstop_data/bitmaps_reference",
"bitmaps_test": "backstop_data/bitmaps_test",
"casper_scripts": "backstop_data/casper_scripts",
"html_report": "backstop_data/html_report",
"ci_report": "backstop_data/ci_report"
},
"casperFlags": [],
"engine": "phantomjs",
"report": []
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
"babel-preset-stage-1": "^6.16.0",
"babel-register": "^6.18.0",
"babel-standalone": "^6.18.2",
"backstopjs": "^2.6.7",
"coveralls": "^2.11.15",
"cross-spawn-promise": "^0.9.2",
"faker": "^4.1.0",
"fs-extra": "^2.0.0",
"gh-pages": "^0.12.0",
"gulp": "^3.9.1",
"html-loader": "^0.4.4",
"httpster": "^1.0.3",
"javascript-natural-sort": "^0.7.1",
"jest": "^19.0.2",
"nsp": "^2.6.2",
Expand Down Expand Up @@ -72,7 +74,9 @@
"storybook": "start-storybook -p 6007",
"secure": "nsp check",
"lint": "standard 'src/**/*.js' '.storybook/**/*.js' 'scripts/**/*.js' 'test/**/*.js' 'stories/**/*.js'",
"test": "echo 'TBD'",
"pretest": "npm run build-storybook",
"test": "node scripts/test",
"test:report": "backstop openReport",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"styleguide": "styleguidist server",
"styleguide:build": "styleguidist build",
Expand Down
30 changes: 30 additions & 0 deletions scripts/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict'

require('perish')

const path = require('path')
const cp = require('child_process')
const projectRoot = path.resolve(__dirname, '..')
const npmBin = path.resolve(projectRoot, 'node_modules', '.bin')

let processHandles = []
function kill () {
processHandles.forEach(handle => {
try {
handle.kill()
} catch (err) {
// pass
}
})
}

const staticContentDir = path.join(projectRoot, 'storybook-static', 'styleguide')
const server = cp.spawn('httpster', ['-d', staticContentDir], { cwd: npmBin, stdio: 'inherit' })
processHandles.push(server.childProcess)

const backstopBin = path.join(npmBin, 'backstop')
const backstop = cp.spawn(backstopBin, ['test'], { cwd: projectRoot, stdio: 'inherit' })
processHandles.push(backstop.childProcess)
backstop.on('exit', code => process.exit(code))

process.on('exit', kill)
8 changes: 0 additions & 8 deletions test/__snapshots__/button.test.js.snap

This file was deleted.

12 changes: 0 additions & 12 deletions test/button.test.js

This file was deleted.

Loading

0 comments on commit 7a67a94

Please sign in to comment.