Skip to content
This repository was archived by the owner on Oct 9, 2020. It is now read-only.

Commit 8a7cc52

Browse files
committed
feat(test): add raw browser testing
1 parent e50829f commit 8a7cc52

File tree

10 files changed

+137
-25
lines changed

10 files changed

+137
-25
lines changed

.travis.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
---
2+
addons:
3+
apt:
4+
packages:
5+
- xvfb
26
git:
37
depth: 1
48
sudo: false
59
cache:
610
directories:
7-
- node_modules
8-
- build-babel/node_modules
911
- build-babel/jspm_packages
12+
- build-babel/node_modules
13+
- node_modules
14+
- test/jspm_packages
15+
- test/jspm_bundles
16+
- test/node_modules
1017
language: node_js
1118
matrix:
1219
include:
@@ -15,6 +22,11 @@ matrix:
1522
- node_js: '4'
1623
- node_js: '5'
1724
- node_js: '6'
25+
install:
26+
- export DISPLAY=':99.0'
27+
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
28+
- npm install
1829
before_script:
1930
- "npm i jspm@beta --prefix build-babel" # Force install in build-babel/node_modules
31+
- "npm run build:tape"
2032
- "npm run build"

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
"jspmPackage": true,
66
"scripts": {
77
"build": "./build.sh",
8+
"build:tape": "test/bundleTape.sh",
89
"clear": "rm -rf build-babel/node_modules build-babel/jspm_packages regenerator-runtime.js systemjs-babel-node.js systemjs-babel-browser.js",
910
"prepublish": "npm run build",
1011
"preversion": "npm run test",
11-
"test": "node test/index.js"
12+
"test": "npm run test:node && npm run test:browser",
13+
"test:node": "node test/index.js",
14+
"test:browser": "cat test/index.html | browser-run --input html --static ./"
1215
},
1316
"main": "plugin-babel.js",
1417
"map": {

test/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/jspm_bundles
2+
/jspm.config.js

test/bundleTape.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash -xv
2+
3+
NODE_CWD=./node_modules/.bin
4+
JSPM_CMD=${NODE_CWD}/jspm
5+
6+
TMP_DIR=test
7+
BUNDLE_DEST_DIR=test
8+
JSPM_VERSION=beta
9+
10+
#
11+
12+
cd $TMP_DIR
13+
14+
npm install jspm@${JSPM_VERSION} --cache-min=Infinity
15+
16+
${JSPM_CMD} install tape=npm:tape --yes --quick --log err
17+
${JSPM_CMD} build tape jspm_bundles/tape.amd-bundle.min.js --format amd --skip-source-maps --skip-rollup --minify --log ok
18+
19+
cd ..

test/index.html

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<script src="test/jspm_packages/system.src.js"></script>
2+
<script type="text/javascript">
3+
System.config({
4+
'map': {
5+
'tape': './test/jspm_bundles/tape.amd-bundle.min.js',
6+
'systemjs': './test/jspm_packages/system.src.js'
7+
},
8+
'packages': {
9+
'systemjs': {
10+
format: 'global'
11+
}
12+
}
13+
})
14+
15+
System.config({
16+
map: {
17+
'plugin-babel': './plugin-babel.js',
18+
'systemjs-babel-build': './systemjs-babel-browser.js'
19+
},
20+
transpiler: 'plugin-babel'
21+
});
22+
</script>
23+
24+
<script type="text/javascript">
25+
SystemJS
26+
.import('./test/scenarios/index.js')
27+
.then(registerTapeOnFinish, window.close);
28+
29+
//
30+
31+
function registerTapeOnFinish() {
32+
SystemJS.import('tape')
33+
.then(function (tape$m) {
34+
tape$m.onFinish(window.close)
35+
})
36+
}
37+
</script>

test/index.js

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,12 @@
33
var test = require('tape');
44
var SystemJS = require('systemjs');
55

6-
test('systemjs-plugin-babel', function (t) {
7-
t.plan(1);
8-
9-
// given
10-
System.config({
11-
map: {
12-
'plugin-babel': './plugin-babel.js',
13-
'systemjs-babel-build': './systemjs-babel-node.js'
14-
},
15-
transpiler: 'plugin-babel'
16-
});
17-
18-
// when
19-
System.import('test/testing-code.js')
20-
21-
// then
22-
.then(function(m) {
23-
return m.p().then(function (message) {
24-
t.equal(message, 'Rocks :)');
25-
});
26-
})
27-
.then(t.end, t.end);
6+
System.config({
7+
map: {
8+
'plugin-babel': './plugin-babel.js',
9+
'systemjs-babel-build': './systemjs-babel-node.js'
10+
},
11+
transpiler: 'plugin-babel'
2812
});
13+
14+
require('./scenarios/index.js');

test/package.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"jspm": {
3+
"dependencies": {
4+
"tape": "npm:tape"
5+
},
6+
"peerDependencies": {
7+
"assert": "github:jspm/nodelibs-assert@^0.2.0-alpha",
8+
"buffer": "github:jspm/nodelibs-buffer@^0.2.0-alpha",
9+
"child_process": "github:jspm/nodelibs-child_process@^0.2.0-alpha",
10+
"events": "github:jspm/nodelibs-events@^0.2.0-alpha",
11+
"fs": "github:jspm/nodelibs-fs@^0.2.0-alpha",
12+
"http": "github:jspm/nodelibs-http@^0.2.0-alpha",
13+
"path": "github:jspm/nodelibs-path@^0.2.0-alpha",
14+
"process": "github:jspm/nodelibs-process@^0.2.0-alpha",
15+
"stream": "github:jspm/nodelibs-stream@^0.2.0-alpha",
16+
"url": "github:jspm/nodelibs-url@^0.2.0-alpha",
17+
"util": "github:jspm/nodelibs-util@^0.2.0-alpha"
18+
},
19+
"overrides": {
20+
"npm:inherits@2.0.1": {
21+
"ignore": [
22+
"test.js"
23+
]
24+
}
25+
}
26+
}
27+
}

test/scenarios/basic/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
var test = require('tape');
4+
var SystemJS = require('systemjs');
5+
6+
test('systemjs-plugin-babel', function (t) {
7+
t.plan(1);
8+
9+
// given
10+
11+
// when
12+
System.import(__dirname + '/actual.js')
13+
14+
// then
15+
.then(function(m) {
16+
return m.p().then(function (message) {
17+
t.equal(message, 'Rocks :)');
18+
});
19+
})
20+
.then(t.end, t.end);
21+
});

test/scenarios/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
//
4+
5+
require('./basic/index.js');

0 commit comments

Comments
 (0)