Skip to content

Commit 68938d6

Browse files
committed
chore: setup e2e tests
1 parent e503674 commit 68938d6

File tree

4 files changed

+55
-3
lines changed

4 files changed

+55
-3
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ cache:
66
notifications:
77
email: true
88
node_js:
9-
- '6'
9+
- '8'
1010
before_script:
1111
- npm prune
1212
script:
1313
- npm test
1414
- npm run example
1515
- node bin/npm-quick-run.js test-foo 'foo bar'
16+
- node bin/npm-quick-run.js echo
1617
after_success:
1718
- npm run semantic-release
1819
branches:

__snapshots__/bin-spec.js

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
exports['quick run bin shows available scripts with prefix 1'] = `
2+
stdout:
3+
-------
4+
running command with prefix "t"
5+
-------
6+
stderr:
7+
-------
8+
Several scripts start with "t" test, test-foo
9+
-------
10+
11+
`
12+
13+
exports['quick run bin runs by prefix 1'] = `
14+
stdout:
15+
-------
16+
running command with prefix "ech"
17+
18+
> echo hello
19+
20+
hello
21+
-------
22+
23+
`

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99
},
1010
"scripts": {
1111
"pretest": "npm run lint",
12-
"test": "mocha --harmony src/*-spec.js",
12+
"unit": "mocha src/*-spec.js",
13+
"test": "npm run unit",
1314
"commit": "git-issues && commit-wizard",
1415
"issues": "git-issues",
1516
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
17+
"echo": "echo hello",
1618
"error": "echo \"an error on purpose\" && exit -1",
1719
"lint": "standard --verbose --fix bin/*.js src/*.js",
1820
"example": "node bin/npm-quick-run.js li",
@@ -72,10 +74,12 @@
7274
}
7375
},
7476
"devDependencies": {
77+
"execa-wrap": "1.2.1",
7578
"git-issues": "1.3.1",
7679
"mocha": "4.0.1",
7780
"pre-git": "3.16.0",
78-
"semantic-release": "6.3.6",
81+
"semantic-release": "8.2.3",
82+
"snap-shot-it": "4.0.1",
7983
"standard": "10.0.3"
8084
},
8185
"release": {

src/bin-spec.js

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const execaWrap = require('execa-wrap')
2+
const snapshot = require('snap-shot-it')
3+
const {join} = require('path')
4+
5+
/* eslint-env mocha */
6+
describe('quick run bin', () => {
7+
const bin = join(__dirname, '..', 'bin', 'npm-quick-run.js')
8+
9+
it('shows available scripts with prefix', () => {
10+
return execaWrap('node', [bin, 't'], {filter: ['stdout', 'stderr']})
11+
.then(snapshot)
12+
})
13+
14+
it('runs by prefix', () => {
15+
const removePath = (s) => {
16+
return s.split('\n')
17+
.filter(s => !s.includes('> npm-quick-run'))
18+
.join('\n')
19+
}
20+
return execaWrap('node', [bin, 'ech'], {filter: ['stdout', 'stderr']})
21+
.then(removePath)
22+
.then(snapshot)
23+
})
24+
})

0 commit comments

Comments
 (0)