diff --git a/.travis.yml b/.travis.yml index 503a8b7..afacb10 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,19 @@ --- +addons: + apt: + packages: + - xvfb git: depth: 1 sudo: false cache: directories: - - node_modules - - build-babel/node_modules - build-babel/jspm_packages + - build-babel/node_modules + - node_modules + - test/jspm_packages + - test/jspm_bundles + - test/node_modules language: node_js matrix: include: @@ -15,6 +22,11 @@ matrix: - node_js: '4' - node_js: '5' - node_js: '6' +install: + - export DISPLAY=':99.0' + - Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 & + - npm install before_script: - "npm i jspm@beta --prefix build-babel" # Force install in build-babel/node_modules + - "npm run build:tape" - "npm run build" diff --git a/package.json b/package.json index 799e745..d69072c 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,13 @@ "jspmPackage": true, "scripts": { "build": "./build.sh", + "build:tape": "test/bundleTape.sh", "clear": "rm -rf build-babel/node_modules build-babel/jspm_packages regenerator-runtime.js systemjs-babel-node.js systemjs-babel-browser.js", "prepublish": "npm run build", "preversion": "npm run test", - "test": "node test/index.js" + "test": "npm run test:node && npm run test:browser", + "test:node": "node test/index.js", + "test:browser": "cat test/index.html | browser-run --input html --static ./" }, "main": "plugin-babel.js", "map": { diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..31f20f6 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1,2 @@ +/jspm_bundles +/jspm.config.js diff --git a/test/bundleTape.sh b/test/bundleTape.sh new file mode 100755 index 0000000..cf2aab9 --- /dev/null +++ b/test/bundleTape.sh @@ -0,0 +1,19 @@ +#!/bin/bash -xv + +NODE_CWD=./node_modules/.bin +JSPM_CMD=${NODE_CWD}/jspm + +TMP_DIR=test +BUNDLE_DEST_DIR=test +JSPM_VERSION=beta + +# + +cd $TMP_DIR + +npm install jspm@${JSPM_VERSION} --cache-min=Infinity + +${JSPM_CMD} install tape=npm:tape --yes --quick --log err +${JSPM_CMD} build tape jspm_bundles/tape.amd-bundle.min.js --format amd --skip-source-maps --skip-rollup --minify --log ok + +cd .. diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..3e08e12 --- /dev/null +++ b/test/index.html @@ -0,0 +1,37 @@ + + + + diff --git a/test/index.js b/test/index.js index 48f3c6f..e06d417 100644 --- a/test/index.js +++ b/test/index.js @@ -3,26 +3,12 @@ var test = require('tape'); var SystemJS = require('systemjs'); -test('systemjs-plugin-babel', function (t) { - t.plan(1); - - // given - System.config({ - map: { - 'plugin-babel': './plugin-babel.js', - 'systemjs-babel-build': './systemjs-babel-node.js' - }, - transpiler: 'plugin-babel' - }); - - // when - System.import('test/testing-code.js') - - // then - .then(function(m) { - return m.p().then(function (message) { - t.equal(message, 'Rocks :)'); - }); - }) - .then(t.end, t.end); +System.config({ + map: { + 'plugin-babel': './plugin-babel.js', + 'systemjs-babel-build': './systemjs-babel-node.js' + }, + transpiler: 'plugin-babel' }); + +require('./scenarios/index.js'); diff --git a/test/package.json b/test/package.json new file mode 100644 index 0000000..c501fe6 --- /dev/null +++ b/test/package.json @@ -0,0 +1,27 @@ +{ + "jspm": { + "dependencies": { + "tape": "npm:tape" + }, + "peerDependencies": { + "assert": "github:jspm/nodelibs-assert@^0.2.0-alpha", + "buffer": "github:jspm/nodelibs-buffer@^0.2.0-alpha", + "child_process": "github:jspm/nodelibs-child_process@^0.2.0-alpha", + "events": "github:jspm/nodelibs-events@^0.2.0-alpha", + "fs": "github:jspm/nodelibs-fs@^0.2.0-alpha", + "http": "github:jspm/nodelibs-http@^0.2.0-alpha", + "path": "github:jspm/nodelibs-path@^0.2.0-alpha", + "process": "github:jspm/nodelibs-process@^0.2.0-alpha", + "stream": "github:jspm/nodelibs-stream@^0.2.0-alpha", + "url": "github:jspm/nodelibs-url@^0.2.0-alpha", + "util": "github:jspm/nodelibs-util@^0.2.0-alpha" + }, + "overrides": { + "npm:inherits@2.0.1": { + "ignore": [ + "test.js" + ] + } + } + } +} diff --git a/test/testing-code.js b/test/scenarios/basic/actual.js similarity index 100% rename from test/testing-code.js rename to test/scenarios/basic/actual.js diff --git a/test/scenarios/basic/index.js b/test/scenarios/basic/index.js new file mode 100644 index 0000000..558f755 --- /dev/null +++ b/test/scenarios/basic/index.js @@ -0,0 +1,21 @@ +'use strict'; + +var test = require('tape'); +var SystemJS = require('systemjs'); + +test('systemjs-plugin-babel', function (t) { + t.plan(1); + + // given + + // when + System.import(__dirname + '/actual.js') + + // then + .then(function(m) { + return m.p().then(function (message) { + t.equal(message, 'Rocks :)'); + }); + }) + .then(t.end, t.end); +}); diff --git a/test/scenarios/index.js b/test/scenarios/index.js new file mode 100644 index 0000000..b4aa8cc --- /dev/null +++ b/test/scenarios/index.js @@ -0,0 +1,5 @@ +'use strict'; + +// + +require('./basic/index.js');