Skip to content

Commit d529a8f

Browse files
authored
use ember-auto-import instead of ember-browserify #2 (#79)
use ember-auto-import instead of ember-browserify
1 parent 4edbb1f commit d529a8f

File tree

32 files changed

+11801
-54
lines changed

32 files changed

+11801
-54
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = {
3939
excludedFiles: [
4040
'app/**',
4141
'addon/**',
42+
'addon-test-support/**',
4243
'tests/dummy/app/**',
4344
'node-tests/fixtures/**'
4445
],

README.md

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,35 +26,20 @@ Installing ember-cli-yadda is a breeze. All you need to do is run the following
2626
ember install ember-cli-yadda
2727
```
2828

29-
This adds the latest version of yadda to your node modules, along with [ember-browserify](https://www.npmjs.com/package/ember-browserify) (to allow yadda to run in the browser). It also adds the following files:
29+
This adds the following files:
3030

3131
```
3232
/tests/acceptance/steps/steps.js
3333
/tests/integration/steps/steps.js
3434
/tests/unit/steps/steps.js
35-
/tests/helpers/yadda.js
3635
/tests/helpers/yadda-annotations.js
3736
```
3837

39-
You may specify the version of yadda by changing it in package.json and running `npm install`.
38+
You may specify the version of yadda by adding it in package.json and running `npm install`.
4039

4140
## Upgrading
4241

43-
To upgrade to the latest version of this addon from a previous release < 0.4.0, including refactoring your existing
44-
tests to Ember's new testing APIs, follow these steps:
45-
46-
- Install the latest version of ember-cli-yadda.
47-
- Run `ember g ember-cli-yadda` to add the most recent files from the blueprint to your project.
48-
- Add the appropriate [setup annotation](#setup-tests) to each Feature or Scenario.
49-
- Refactor your step files to use the new testing APIs:
50-
- for application tests, skip using Ember's global test helpers and use those provided by [@ember/test-helpers](https://github.com/emberjs/ember-test-helpers).
51-
- use `async`/`await` for all asynchronous operations, including `andThen()`
52-
- [ember-test-helpers-codemod](https://github.com/simonihmig/ember-test-helpers-codemod) will be able to do most of
53-
these changes automatically
54-
- For further details have a look at the [Migration Guide for QUnit](https://github.com/emberjs/ember-qunit/blob/master/docs/migration.md)
55-
or the [Migration Guide for Mocha](https://github.com/emberjs/ember-mocha/blob/master/docs/migration.md#upgrading-to-the-new-testing-apis)
56-
- *Optional*: customize `tests/helpers/yadda-annotations.js` with any additional setup logic that is needed, see
57-
[here](#customization)
42+
See the [Release Notes](https://github.com/albertjan/ember-cli-yadda/releases).
5843

5944
## Usage
6045

@@ -129,7 +114,7 @@ Because we probably have more features about bananas, we add the `Given I have b
129114
`/tests/acceptance/steps.js`
130115

131116
```js
132-
import yadda from '../../helpers/yadda';
117+
import { yadda } from 'ember-cli-yadda';
133118
import { visit } from '@ember/test-helpers';
134119

135120
export default function(assert) {

addon-test-support/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import yadda from 'yadda';
2+
export { yadda };

blueprints/main-index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ module.exports = {
44
name: 'ember-cli-yadda',
55
description: 'ember-cli-yadda',
66
normalizeEntityName() {
7-
},
8-
afterInstall() {
9-
return this.addAddonToProject('ember-browserify');
107
}
118
};

blueprints/mocha/ember-cli-yadda/files/tests/acceptance/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { expect } from 'chai';
33
import { visit } from '@ember/test-helpers';
44

blueprints/mocha/ember-cli-yadda/files/tests/helpers/yadda.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

blueprints/mocha/ember-cli-yadda/files/tests/integration/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { expect } from 'chai';
33

44
export default function() {

blueprints/mocha/ember-cli-yadda/files/tests/unit/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { expect } from 'chai';
33

44
export default function() {

blueprints/qunit/ember-cli-yadda/files/tests/acceptance/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { visit } from '@ember/test-helpers';
33

44
export default function(assert) {

blueprints/qunit/ember-cli-yadda/files/tests/helpers/yadda.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

blueprints/qunit/ember-cli-yadda/files/tests/integration/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22

33
export default function(assert) {
44
return yadda.localisation.default.library()

blueprints/qunit/ember-cli-yadda/files/tests/unit/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22

33
export default function(assert) {
44
return yadda.localisation.default.library()

docs/legacy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Feature: bananas rot
118118
Because we probably have more features about bananas. We add the `Given I have bananas` to the global steps file: `/tests/acceptance/steps.js`
119119

120120
```js
121-
import yadda from '../../helpers/yadda';
121+
import { yadda } from '../../helpers/yadda';
122122

123123
export default function(assert) {
124124
return yadda.localisation.English.library()

index.js

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ const FeatureParser = require('./lib/feature-parser');
55

66
module.exports = {
77
name: 'ember-cli-yadda',
8+
options: {
9+
autoImport:{
10+
exclude: ['mocha'],
11+
webpack: {
12+
node: {
13+
fs: "empty"
14+
}
15+
}
16+
}
17+
},
818
getTestFramework() {
919
let dependencies = this.project.dependencies();
1020
if ('ember-cli-mocha' in dependencies || 'ember-mocha' in dependencies) {
@@ -28,11 +38,30 @@ module.exports = {
2838
return path.join(__dirname, 'blueprints', this.getTestFramework());
2939
},
3040
included(app) {
31-
this._super.included(app);
41+
this._super.included.apply(this, arguments);
3242
let options = app.options['ember-cli-yadda'] || {};
3343
if (typeof options.persist === 'undefined') {
3444
options.persist = true;
3545
}
3646
this._options = options;
47+
},
48+
treeForAddonTestSupport(tree) {
49+
// intentionally not calling _super here
50+
// so that can have our `import`'s be
51+
// import { yadda } from 'ember-cli-yadda';
52+
// shamelessly stolen from https://github.com/cibernox/ember-native-dom-helpers/blob/19adea1683fc386baca6eb7c83cd0a147bd4d586/index.js
53+
// and https://github.com/kaliber5/ember-window-mock/blob/master/index.js#L7-L24
54+
55+
const Funnel = require('broccoli-funnel');
56+
57+
let namespacedTree = new Funnel(tree, {
58+
srcDir: '/',
59+
destDir: `/${this.moduleName()}`,
60+
annotation: `Addon#treeForTestSupport (${this.name})`,
61+
});
62+
63+
return this.preprocessJs(namespacedTree, '/', this.name, {
64+
registry: this.registry,
65+
});
3766
}
3867
};

lib/feature-parser.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ class FeatureParser extends Filter {
3535
let nestedFolderParts = pathParts.slice(3, -1);
3636
let stepsPath = [basePath, testFolder, 'steps', ...nestedFolderParts].join('/');
3737

38+
// import testRunner from 'ember-cli-yadda/test-support/${this.testFramework}/test-runner';
39+
3840
let module = `
39-
import yadda from '${basePath}/helpers/yadda';
41+
import { yadda } from 'ember-cli-yadda';
4042
import * as library from '${stepsPath}/${fileName}-steps';
4143
import yaddaAnnotations from '${basePath}/helpers/yadda-annotations';
42-
import testRunner from 'ember-cli-yadda/test-support/${this.testFramework}/test-runner';
44+
import testRunner from 'ember-cli-yadda/${this.testFramework}/test-runner';
4345
4446
const feature = ${JSON.stringify(feature, null, 2)};
4547

node-tests/blueprints/main-test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ describe('Acceptance: ember generate ember-cli-yadda', function() {
4747
let args = ['ember-cli-yadda'];
4848

4949
let fixtureFiles = [
50-
'helpers/yadda.js',
51-
'helpers/yadda-annotations.js',
50+
'helpers/yadda-annotations.js'
5251
].concat(
5352
testTypes.map((type) => `${type}/steps/steps.js`)
5453
);

node-tests/fixtures/main/mocha/acceptance/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { expect } from 'chai';
33
import { visit } from '@ember/test-helpers';
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import yadda from 'npm:yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
export default yadda;

node-tests/fixtures/main/mocha/integration/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { expect } from 'chai';
33

44
export default function() {

node-tests/fixtures/main/mocha/unit/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { expect } from 'chai';
33

44
export default function() {

node-tests/fixtures/main/qunit/acceptance/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
import { visit } from '@ember/test-helpers';
33

44
export default function(assert) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import yadda from 'npm:yadda';
1+
import { yadda } from 'ember-cli-yadda';
22
export default yadda;

node-tests/fixtures/main/qunit/integration/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22

33
export default function(assert) {
44
return yadda.localisation.default.library()

node-tests/fixtures/main/qunit/unit/steps/steps.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import yadda from '../../helpers/yadda';
1+
import { yadda } from 'ember-cli-yadda';
22

33
export default function(assert) {
44
return yadda.localisation.default.library()

0 commit comments

Comments
 (0)