Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Switch from karma to testem; better broccoli integration #61

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions bin/movable
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@

process.title = 'movable';

const cli = require('../lib/cli');
var resolve = require('resolve');
var exit = require('exit');

cli({
cliArgs: process.argv.slice(2),
inputStream: process.stdin,
outputStream: process.stdout,
errorStream: process.stderr,
cli: {
name: 'movable',
npmPackage: '@movable/cli',
root: require('path').resolve(__dirname, '..')
resolve('@movable/cli', {
basedir: process.cwd()
}, function(error, projectLocalCli) {
var cli;
if (error) {
// If there is an error, resolve could not find the ember-cli
// library from a package.json. Instead, include it from a relative
// path to this script file (which is likely a globally installed
// npm package). Most common cause for hitting this is `ember new`
cli = require('../lib/cli');
} else {
// No error implies a projectLocalCli, which will load whatever
// version of ember-cli you have installed in a local package.json
cli = require(projectLocalCli);
}
}).then(function(result) {
var exitCode = typeof result === 'object' ? result.exitCode : result;
exit(exitCode);

cli({
cliArgs: process.argv.slice(2),
inputStream: process.stdin,
outputStream: process.stdout,
errorStream: process.stderr,
cli: {
name: 'movable',
npmPackage: '@movable/cli',
root: require('path').resolve(__dirname, '..')
}
}).then(function(result) {
var exitCode = typeof result === 'object' ? result.exitCode : result;
exit(exitCode);
});
});
60 changes: 60 additions & 0 deletions blueprints/app/files/build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const MovableApp = require('@movable/cli/lib/broccoli/movable-app');
const sourcemapPathTransform = require('@movable/cli/lib/broccoli/sourcemap-path-transform');

const resolve = require("rollup-plugin-node-resolve");
const commonjs = require("rollup-plugin-commonjs");
const html = require("@movable/rollup-plugin-html");
const { importExportToGlobal, dependenciesOnly } = require("rollup-split-index");

module.exports = function(defaults) {
const app = new MovableApp(defaults, {
rollup: {
// dist/index.js contains a rewritten app/js/index.js
index: {
input: 'app/js/index.js',
plugins: [
resolve(),
commonjs(),
importExportToGlobal({
importName: 'studioDependencies'
})
],
output: {
file: "index.js",
// output format is es6, but with imports/exports rewritten to es5
format: "es",
sourcemap: true,
sourcemapPathTransform
}
},
// dist/vendor.js contains everything that app/js/index.js imports, in one file
vendor: {
// only used to determine which files to include in vendor tree
input: 'app/js/index.js',
plugins: [resolve(), commonjs(), dependenciesOnly()],
output: {
// Vendor dependencies will be stored in the global namespace under this variable name
name: "studioDependencies",
file: "vendor.js",
format: "iife",
sourcemap: true,
sourcemapPathTransform
}
},
// dists/tests.js bundles everything from tests/tests.js
tests: {
input: 'tests/tests.js',
plugins: [html({ include: /\.html$/ }), resolve(), commonjs()],
output: {
file: "tests.js",
format: "iife",
sourcemap: true,
sourcemapPathTransform
}
}

}
});

return app.toTree();
};
1 change: 1 addition & 0 deletions blueprints/app/files/gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
.idea
npm-debug.log
yarn-error.log
.DS_Store
/dist
/tmp
17 changes: 0 additions & 17 deletions blueprints/app/files/karma.conf.js

This file was deleted.

28 changes: 13 additions & 15 deletions blueprints/app/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,26 @@
"test": "tests"
},
"scripts": {
"build": "node_modules/.bin/rollup -c rollup.config.js",
"start": "SERVE=true node_modules/.bin/rollup -c rollup.config.js",
"test": "node_modules/.bin/karma start --single-run --browsers ChromeHeadless"
"build": "movable build",
"start": "movable serve",
"test": "movable test"
},
"repository": "",
"author": "",
"license": "SEE LICENSE IN LICENSE.md",
"homepage": "",
"dependencies": {
"cropduster": "^6.0.0",
"jquery": "^3.2.1",
"studio-app": "^1.5.0"
"@movable/cli": "0.19.0"
},
"devDependencies": {
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-html2js-preprocessor": "^1.1.0",
"karma-qunit": "^1.2.1",
"karma-rollup-preprocessor": "https://github.com/movableink/karma-rollup-preprocessor#multi-config",
"qunit": "^1.0.0",
"rollup": "^0.51.3",
"rollup-plugin-serve": "0.4.2",
"rollup-split-index": "https://github.com/movableink/rollup-split-index.git#e4d355d"
"@movable/rollup-plugin-html": "^0.3.0",
"cropduster": "^6.0.0",
"jquery": "^3.2.1",
"qunit": "^2.8.0",
"rollup": "^0.67.4",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-split-index": "^1.0.1",
"studio-app": "^1.7.2"
}
}
24 changes: 24 additions & 0 deletions blueprints/app/files/testem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
test_page: 'tests/index.html?hidepassed',
disable_watching: true,
launch_in_ci: [
'Chrome'
],
launch_in_dev: [
'Chrome'
],
browser_args: {
Chrome: {
mode: 'ci',
args: [
// --no-sandbox is needed when running Chrome inside a container
process.env.TRAVIS ? '--no-sandbox' : null,

'--disable-gpu',
'--headless',
'--remote-debugging-port=0',
'--window-size=1440,900'
].filter(Boolean)
}
}
};
6 changes: 4 additions & 2 deletions blueprints/app/files/tests/helper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import index from './index.html';

const common = {
startComment:
'<!-- MI WYSIWYG: DO NOT MODIFY CODE BEYOND THIS POINT. This code is auto-generated by Studio and will be overwritten -->',
Expand All @@ -6,8 +8,8 @@ const common = {
};
common.regex = new RegExp(`(${common.startCommentReg}|${common.finishComment})`, 'm');

function wysiwygContent() {
const parts = window.__html__['app/index.html'].split(common.regex);
export function wysiwygContent() {
const parts = index.split(common.regex);
if (parts.length !== 5) {
throw 'missing wysiwyg block from html';
}
Expand Down
29 changes: 29 additions & 0 deletions blueprints/app/files/tests/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><%= name %> Tests</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet" href="./test-support.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>

<div id="ember-testing-container">
<div id="ember-testing"></div>
</div>


<script src="/testem.js" integrity=""></script>

<script src="../vendor.js"></script>
<script src="../index.js"></script>

<script src="./test-support.js"></script>
<script src="./tests.js"></script>
</body>
</html>
4 changes: 4 additions & 0 deletions blueprints/app/files/tests/tests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/* global QUnit */
import CD from 'cropduster';
import { wysiwygContent } from './helper';

const container = document.createElement('div');
container.classNames = 'container';
document.body.appendChild(container);
Expand Down
Loading