diff --git a/.travis.yml b/.travis.yml index 92128c31..d477f779 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,6 @@ cache: env: - EMBER_TRY_SCENARIO=default - EMBER_TRY_SCENARIO=old-test-loader - - EMBER_TRY_SCENARIO=npm-test-loader - EMBER_TRY_SCENARIO=ember-release - EMBER_TRY_SCENARIO=ember-beta - EMBER_TRY_SCENARIO=ember-canary diff --git a/addon-test-support/ember-cli-qunit.js b/addon-test-support/ember-cli-qunit.js index 96848a6a..f8ef53fa 100644 --- a/addon-test-support/ember-cli-qunit.js +++ b/addon-test-support/ember-cli-qunit.js @@ -1,131 +1,9 @@ -import Ember from 'ember'; -import QUnit from 'qunit'; -import { QUnitAdapter } from 'ember-qunit'; -import AbstractTestLoader, { - addModuleExcludeMatcher, - addModuleIncludeMatcher -} from 'ember-cli-test-loader/test-support/index'; - - -addModuleExcludeMatcher(function(moduleName) { - return QUnit.urlParams.nolint && - moduleName.match(/\.(jshint|lint-test)$/); -}); - -addModuleIncludeMatcher(function(moduleName) { - return moduleName.match(/\.jshint$/); -}); - -let moduleLoadFailures = []; - -QUnit.done(function() { - if (moduleLoadFailures.length) { - throw new Error('\n' + moduleLoadFailures.join('\n')); - } -}); - -export class TestLoader extends AbstractTestLoader { - moduleLoadFailure(moduleName, error) { - moduleLoadFailures.push(error); - - QUnit.module('TestLoader Failures'); - QUnit.test(moduleName + ': could not be loaded', function() { - throw error; - }); - } -} -/** - Uses current URL configuration to setup the test container. - - * If `?nocontainer` is set, the test container will be hidden. - * If `?dockcontainer` or `?devmode` are set the test container will be - absolutely positioned. - * If `?devmode` is set, the test container will be made full screen. - - @method setupTestContainer - */ -export function setupTestContainer() { - let testContainer = document.getElementById('ember-testing-container'); - if (!testContainer) { return; } - - let params = QUnit.urlParams; - - let containerVisibility = params.nocontainer ? 'hidden' : 'visible'; - let containerPosition = (params.dockcontainer || params.devmode) ? 'fixed' : 'relative'; - - if (params.devmode) { - testContainer.className = ' full-screen'; - } - - testContainer.style.visibility = containerVisibility; - testContainer.style.position = containerPosition; - - let qunitContainer = document.getElementById('qunit'); - if (params.dockcontainer) { - qunitContainer.style.marginBottom = window.getComputedStyle(testContainer).height; - } -} - -/** - Load tests following the default patterns: - - * The module name ends with `-test` - * The module name ends with `.jshint` - - Excludes tests that match the following - patterns when `?nolint` URL param is set: - - * The module name ends with `.jshint` - * The module name ends with `-lint-test` - - @method loadTests - */ -export function loadTests() { - new TestLoader().loadModules(); -} - -/** - Instruct QUnit to start the tests. - @method startTests - */ -export function startTests() { - QUnit.start(); -} - -/** - Sets up the `Ember.Test` adapter for usage with QUnit 2.x. - - @method setupTestAdapter - */ -export function setupTestAdapter() { - Ember.Test.adapter = QUnitAdapter.create(); -} - -/** - @method start - @param {Object} [options] Options to be used for enabling/disabling behaviors - @param {Boolean} [options.loadTests] If `false` tests will not be loaded automatically. - @param {Boolean} [options.setupTestContainer] If `false` the test container will not - be setup based on `devmode`, `dockcontainer`, or `nocontainer` URL params. - @param {Boolean} [options.startTests] If `false` tests will not be automatically started - (you must run `QUnit.start()` to kick them off). - @param {Boolean} [options.setupTestAdapter] If `false` the default Ember.Test adapter will - not be updated. - */ -export function start(options = { }) { - if (options.loadTests !== false) { - loadTests(); - } - - if (options.setupTestContainer !== false) { - setupTestContainer(); - } - - if (options.setupTestAdapter !== false) { - setupTestAdapter(); - } - - if (options.startTests !== false) { - startTests(); - } -} +// reexporting for compatibility +export { + TestLoader, + setupTestContainer, + loadTests, + startTests, + setupTestAdapter, + start +} from 'ember-qunit'; diff --git a/config/ember-try.js b/config/ember-try.js index 157fd828..0bfa9fe2 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -1,27 +1,19 @@ /*jshint node:true*/ module.exports = { scenarios: [ - { - name: 'default', - bower: { - dependencies: { - 'ember-cli-test-loader': '0.2.2' - } - } - }, { name: 'old-test-loader', bower: { dependencies: { - 'ember-cli-test-loader': '0.2.0' + 'ember-cli-test-loader': '0.2.2' } } }, { - name: 'npm-test-loader', + name: 'default', npm: { devDependencies: { - 'ember-cli-test-loader': '^1.1.0' + 'ember-cli-test-loader': '^2.2.0' } } }, @@ -30,11 +22,15 @@ module.exports = { bower: { dependencies: { 'ember': 'components/ember#release', - 'ember-cli-test-loader': '0.2.2' }, resolutions: { 'ember': 'release' } + }, + npm: { + devDependencies: { + 'ember-cli-test-loader': '^2.2.0' + } } }, { @@ -42,10 +38,14 @@ module.exports = { bower: { dependencies: { 'ember': 'components/ember#beta', - 'ember-cli-test-loader': '0.2.2' }, resolutions: { - 'ember': 'beta' + 'ember': 'beta', + } + }, + npm: { + devDependencies: { + 'ember-cli-test-loader': '^2.2.0', } } }, @@ -54,10 +54,14 @@ module.exports = { bower: { dependencies: { 'ember': 'components/ember#canary', - 'ember-cli-test-loader': '0.2.2' }, resolutions: { - 'ember': 'canary' + 'ember': 'canary', + } + }, + npm: { + devDependencies: { + 'ember-cli-test-loader': '^2.2.0', } } } diff --git a/index.js b/index.js index 1abd34b8..a521ccb8 100644 --- a/index.js +++ b/index.js @@ -1,162 +1,14 @@ 'use strict'; -const path = require('path'); -const fs = require('fs'); -const resolve = require('resolve'); - module.exports = { name: 'ember-cli-qunit', - _getDependencyTrees: function() { - if (this._dependencyTrees) { - return this._dependencyTrees; - } - - let emberQUnitPath = path.dirname(resolve.sync('ember-qunit')); - let emberTestHelpersPath = path.dirname(resolve.sync('ember-test-helpers', { basedir: emberQUnitPath })); - - this._dependencyTrees = [ - this.treeGenerator(emberQUnitPath), - this.treeGenerator(emberTestHelpersPath), - ]; - - return this._dependencyTrees; - }, - - init: function() { - this._super.init && this._super.init.apply(this, arguments); - - const VersionChecker = require('ember-cli-version-checker'); - let checker = new VersionChecker(this); - let dep = checker.for('ember-cli', 'npm'); - - if (!dep.gt('2.2.0-beta.2')) { - const SilentError = require('silent-error'); - throw new SilentError('ember-cli-qunit@3.0.0 and higher requires at least ember-cli@2.2.0. Please downgrade to ember-cli-qunit@2 for older ember-cli version support.'); - } - - this._shouldPreprocessAddonTestSupport = !!this.options && !!this.options.babel; - - this.setTestGenerator(); - }, - - blueprintsPath: function() { - return path.join(__dirname, 'blueprints'); - }, - // intentionally not calling _super here // to avoid these trees being namespaced into // `ember-cli-qunit/test-support/` - treeForAddonTestSupport: function(onDiskAddonTestSupportTree) { - const MergeTrees = require('broccoli-merge-trees'); - let trees = [].concat( - this._getDependencyTrees(), - onDiskAddonTestSupportTree - ); - let tree = new MergeTrees(trees); - - if (this._shouldPreprocessAddonTestSupport) { - return this.preprocessJs(tree, { - registry: this.registry - }); - } else { - return tree; - } - }, - - treeForVendor: function(tree) { - const MergeTrees = require('broccoli-merge-trees'); - let qunitPath = path.join(path.dirname(resolve.sync('qunitjs')), '..'); - - let trees = [ - tree, - this._notificationsTree(), - this.treeGenerator(qunitPath) - ]; - - return new MergeTrees(trees, { - annotation: 'ember-cli-qunit: treeForVendor' + treeForAddonTestSupport: function(tree) { + return this.preprocessJs(tree, { + registry: this.registry }); }, - - included: function included(app, parentAddon) { - let target = (parentAddon || app); - this._super.included.call(this, target); - - this.targetOptions = target.options; - - let testSupportPath = target.options.outputPaths.testSupport.js; - testSupportPath = testSupportPath.testSupport || testSupportPath; - testSupportPath = path.dirname(testSupportPath) || 'assets'; - - if (app.tests) { - let fileAssets = [ - 'vendor/qunit/qunit.js', - 'vendor/qunit/qunit.css', - 'vendor/qunit-notifications/index.js', - 'vendor/ember-cli-qunit/qunit-configuration.js', - ]; - - let addonOptions = target.options['ember-cli-qunit']; - let hasAddonOptions = !!addonOptions; - let explicitlyDisabledContainerStyles = hasAddonOptions && addonOptions.disableContainerStyles === true; - if (!explicitlyDisabledContainerStyles) { - fileAssets.push('vendor/ember-cli-qunit/test-container-styles.css'); - } - - fileAssets.forEach(function(file){ - app.import(file, { - type: 'test' - }); - }); - - let imgAssets = [ - 'vendor/ember-cli-qunit/images/passed.png', - 'vendor/ember-cli-qunit/images/failed.png' - ]; - - imgAssets.forEach(function(img) { - app.import(img, { - type: 'test', - destDir: testSupportPath - }); - }); - } - }, - - _notificationsTree: function() { - const Funnel = require('broccoli-funnel'); - let notificationsPath = path.dirname(resolve.sync('qunit-notifications')); - return new Funnel(notificationsPath, { - include: [ 'index.js' ], - destDir: 'qunit-notifications', - annotation: 'qunit-notifications' - }); - }, - - contentFor: function(type) { - // Skip if insertContentForTestBody === false. - if (type === 'test-body' && !(this.targetOptions['ember-cli-qunit'] && this.targetOptions['ember-cli-qunit'].insertContentForTestBody === false)) { - return this._readTemplate('test-body'); - } - }, - - _readTemplate: function(name) { - return fs.readFileSync(path.join(__dirname, 'templates', name + '.html')); - }, - - setTestGenerator: function() { - this.project.generateTestFile = function(moduleName, tests) { - let output = "QUnit.module('" + moduleName + "');\n"; - - tests.forEach(function(test) { - output += "QUnit.test('" + test.name + "', function(assert) {\n"; - output += " assert.expect(1);\n"; - output += " assert.ok(" + test.passed + ", '" + test.errorMessage + "');\n"; - output += "});\n"; - }); - - return output; - }; - } }; diff --git a/package.json b/package.json index 3227a564..26a68d0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ember-cli-qunit", - "version": "4.0.1", + "version": "4.1.0-beta.0", "description": "QUnit testing package for ember-cli applications", "main": "index.js", "engines": { @@ -22,30 +22,26 @@ "ember", "qunit" ], - "author": "Jake Craige ", + "contributors": [ + "Jake Craige", + "Stefan Penner", + "Robert Jackson" + ], "license": "MIT", "bugs": { "url": "https://github.com/ember-cli/ember-cli-qunit/issues" }, "homepage": "https://github.com/ember-cli/ember-cli-qunit", "dependencies": { - "broccoli-funnel": "^2.0.0", - "broccoli-merge-trees": "^2.0.0", "ember-cli-babel": "^6.8.1", - "ember-cli-test-loader": "^2.2.0", - "ember-cli-version-checker": "^2.0.0", - "ember-qunit": "^2.2.0", - "qunit-notifications": "^0.1.1", - "qunitjs": "^2.4.0", - "resolve": "^1.4.0", - "silent-error": "^1.1.0" + "ember-qunit": "^3.0.0-beta.2" }, "devDependencies": { "ember-cli": "^2.4.2", "ember-cli-htmlbars": "^2.0.3", + "ember-cli-test-loader": "^2.2.0", "ember-load-initializers": "^1.0.0", "ember-resolver": "^4.4.0", - "ember-try": "^0.2.16", "loader.js": "^4.6.0" } } diff --git a/templates/test-body.html b/templates/test-body.html deleted file mode 100644 index 7c4ab02d..00000000 --- a/templates/test-body.html +++ /dev/null @@ -1,6 +0,0 @@ -
-
- -
-
-
diff --git a/vendor/ember-cli-qunit/images/failed.png b/vendor/ember-cli-qunit/images/failed.png deleted file mode 100644 index 37e8870e..00000000 Binary files a/vendor/ember-cli-qunit/images/failed.png and /dev/null differ diff --git a/vendor/ember-cli-qunit/images/passed.png b/vendor/ember-cli-qunit/images/passed.png deleted file mode 100644 index d4e4fca8..00000000 Binary files a/vendor/ember-cli-qunit/images/passed.png and /dev/null differ diff --git a/vendor/ember-cli-qunit/qunit-configuration.js b/vendor/ember-cli-qunit/qunit-configuration.js deleted file mode 100644 index f21cb650..00000000 --- a/vendor/ember-cli-qunit/qunit-configuration.js +++ /dev/null @@ -1,20 +0,0 @@ -/* globals QUnit */ - -(function() { - QUnit.config.autostart = false; - QUnit.config.urlConfig.push({ id: 'nocontainer', label: 'Hide container'}); - QUnit.config.urlConfig.push({ id: 'nolint', label: 'Disable Linting'}); - QUnit.config.urlConfig.push({ id: 'dockcontainer', label: 'Dock container'}); - QUnit.config.urlConfig.push({ id: 'devmode', label: 'Development mode' }); - - QUnit.config.testTimeout = QUnit.urlParams.devmode ? null : 60000; //Default Test Timeout 60 Seconds - - if (QUnit.notifications) { - QUnit.notifications({ - icons: { - passed: '/assets/passed.png', - failed: '/assets/failed.png' - } - }); - } -})(); diff --git a/vendor/ember-cli-qunit/test-container-styles.css b/vendor/ember-cli-qunit/test-container-styles.css deleted file mode 100644 index 99c42a36..00000000 --- a/vendor/ember-cli-qunit/test-container-styles.css +++ /dev/null @@ -1,34 +0,0 @@ -#ember-testing-container { - position: relative; - background: white; - bottom: 0; - right: 0; - width: 640px; - height: 384px; - overflow: auto; - z-index: 98; - border: 1px solid #ccc; - margin: 0 auto; -} - -#ember-testing-container.full-screen { - width: 100%; - height: 100%; - overflow: auto; - z-index: 98; - border: none; -} - -#ember-testing { - width: 200%; - height: 200%; - transform: scale(0.5); - transform-origin: top left; -} - -.full-screen #ember-testing { - position: absolute; - width: 100%; - height: 100%; - transform: scale(1); -} diff --git a/yarn.lock b/yarn.lock index e771d89a..a3a54ab9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -469,6 +469,12 @@ babel-plugin-ember-modules-api-polyfill@^1.5.1: dependencies: ember-rfc176-data "^0.2.0" +babel-plugin-ember-modules-api-polyfill@^2.0.1: + version "2.1.0" + resolved "https://registry.yarnpkg.com/babel-plugin-ember-modules-api-polyfill/-/babel-plugin-ember-modules-api-polyfill-2.1.0.tgz#78848cc4fcc2274882a6c15cbb23fefcdc771301" + dependencies: + ember-rfc176-data "^0.3.0" + babel-plugin-eval@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/babel-plugin-eval/-/babel-plugin-eval-1.0.1.tgz#a2faed25ce6be69ade4bfec263f70169195950da" @@ -1150,15 +1156,14 @@ broccoli-funnel@^1.1.0: symlink-or-copy "^1.0.0" walk-sync "^0.3.1" -broccoli-funnel@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/broccoli-funnel/-/broccoli-funnel-2.0.0.tgz#12bec71c34118eedb0cc1d9a3a41df97b6b0c73b" +broccoli-funnel@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/broccoli-funnel/-/broccoli-funnel-2.0.1.tgz#6823c73b675ef78fffa7ab800f083e768b51d449" dependencies: array-equal "^1.0.0" blank-object "^1.0.1" broccoli-plugin "^1.3.0" debug "^2.2.0" - exists-sync "0.0.4" fast-ordered-set "^1.0.0" fs-tree-diff "^0.5.3" heimdalljs "^0.2.0" @@ -1513,6 +1518,12 @@ commander@2.9.0, commander@^2.5.0, commander@^2.6.0: dependencies: graceful-readlink ">= 1.0.0" +common-tags@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.4.0.tgz#1187be4f3d4cf0c0427d43f74eef1f73501614c0" + dependencies: + babel-runtime "^6.18.0" + commoner@~0.10.3: version "0.10.8" resolved "https://registry.yarnpkg.com/commoner/-/commoner-0.10.8.tgz#34fc3672cd24393e8bb47e70caa0293811f4f2c5" @@ -1827,6 +1838,23 @@ ember-cli-babel@^6.0.0-beta.7: clone "^2.0.0" ember-cli-version-checker "^1.2.0" +ember-cli-babel@^6.3.0: + version "6.8.2" + resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.8.2.tgz#eac2785964f4743f4c815cd53c6288f00cc087d7" + dependencies: + amd-name-resolver "0.0.7" + babel-plugin-debug-macros "^0.1.11" + babel-plugin-ember-modules-api-polyfill "^2.0.1" + babel-plugin-transform-es2015-modules-amd "^6.24.0" + babel-polyfill "^6.16.0" + babel-preset-env "^1.5.1" + broccoli-babel-transpiler "^6.1.2" + broccoli-debug "^0.6.2" + broccoli-funnel "^1.0.0" + broccoli-source "^1.1.0" + clone "^2.0.0" + ember-cli-version-checker "^2.0.0" + ember-cli-babel@^6.8.1: version "6.8.1" resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.8.1.tgz#695f94c57a9375c2a0e219306a41105d6b937991" @@ -2052,11 +2080,17 @@ ember-load-initializers@^1.0.0: dependencies: ember-cli-babel "^6.0.0-beta.7" -ember-qunit@^2.2.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/ember-qunit/-/ember-qunit-2.2.0.tgz#3cdf400031c93a38de781a7304819738753b7f99" +ember-qunit@^3.0.0-beta.2: + version "3.0.0-beta.2" + resolved "https://registry.yarnpkg.com/ember-qunit/-/ember-qunit-3.0.0-beta.2.tgz#e6ab5872f6d37456d80405c8c42ac4fb528e5b84" dependencies: - ember-test-helpers "^0.6.3" + broccoli-funnel "^2.0.1" + broccoli-merge-trees "^2.0.0" + common-tags "^1.4.0" + ember-cli-babel "^6.3.0" + ember-cli-test-loader "^2.2.0" + ember-test-helpers "^0.7.0-beta.2" + qunitjs "^2.4.0" ember-resolver@^4.4.0: version "4.4.0" @@ -2074,15 +2108,22 @@ ember-rfc176-data@^0.2.0: version "0.2.5" resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.2.5.tgz#b26f62d9c03d3b02485153cf31137e089299839a" +ember-rfc176-data@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/ember-rfc176-data/-/ember-rfc176-data-0.3.0.tgz#6aee728cb521c5f80710990965027b9c320f6f08" + ember-router-generator@^1.0.0: version "1.2.3" resolved "https://registry.yarnpkg.com/ember-router-generator/-/ember-router-generator-1.2.3.tgz#8ed2ca86ff323363120fc14278191e9e8f1315ee" dependencies: recast "^0.11.3" -ember-test-helpers@^0.6.3: - version "0.6.3" - resolved "https://registry.yarnpkg.com/ember-test-helpers/-/ember-test-helpers-0.6.3.tgz#f864cdf6f4e75f3f8768d6537785b5ab6e82d907" +ember-test-helpers@^0.7.0-beta.2: + version "0.7.0-beta.2" + resolved "https://registry.yarnpkg.com/ember-test-helpers/-/ember-test-helpers-0.7.0-beta.2.tgz#da3716c4149ee0693cab50f91491c8200c98d33c" + dependencies: + broccoli-funnel "^2.0.1" + ember-cli-babel "^6.8.1" ember-try-config@^2.0.1: version "2.1.0" @@ -2093,24 +2134,6 @@ ember-try-config@^2.0.1: rsvp "^3.2.1" semver "^5.1.0" -ember-try@^0.2.16: - version "0.2.16" - resolved "https://registry.yarnpkg.com/ember-try/-/ember-try-0.2.16.tgz#cf7092d8a8fea9701d7faa73cbdbff37a8ada330" - dependencies: - chalk "^1.0.0" - cli-table2 "^0.2.0" - core-object "^1.1.0" - debug "^2.2.0" - ember-cli-version-checker "^1.1.6" - ember-try-config "^2.0.1" - extend "^3.0.0" - fs-extra "^0.26.0" - promise-map-series "^0.2.1" - resolve "^1.1.6" - rimraf "^2.3.2" - rsvp "^3.0.17" - semver "^5.1.0" - ember-try@^0.2.9: version "0.2.12" resolved "https://registry.yarnpkg.com/ember-try/-/ember-try-0.2.12.tgz#27ea2305ca097b9e0884565c96da2402d6e841aa" @@ -3912,10 +3935,6 @@ quick-temp@0.1.6, quick-temp@^0.1.2, quick-temp@^0.1.3, quick-temp@^0.1.5: rimraf "~2.2.6" underscore.string "~2.3.3" -qunit-notifications@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/qunit-notifications/-/qunit-notifications-0.1.1.tgz#3001afc6a6a77dfbd962ccbcddde12dec5286c09" - qunitjs@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/qunitjs/-/qunitjs-2.4.0.tgz#58f3a81e846687f2e7f637c5bedc9c267f887261" @@ -4153,12 +4172,6 @@ resolve@^1.3.3: dependencies: path-parse "^1.0.5" -resolve@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.4.0.tgz#a75be01c53da25d934a98ebd0e4c4a7312f92a86" - dependencies: - path-parse "^1.0.5" - restore-cursor@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" @@ -4291,12 +4304,6 @@ silent-error@^1.0.0, silent-error@^1.0.1: dependencies: debug "^2.2.0" -silent-error@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/silent-error/-/silent-error-1.1.0.tgz#2209706f1c850a9f1d10d0d840918b46f26e1bc9" - dependencies: - debug "^2.2.0" - simple-fmt@~0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/simple-fmt/-/simple-fmt-0.1.0.tgz#191bf566a59e6530482cb25ab53b4a8dc85c3a6b"