├── .dependabot └── config.yml ├── .editorconfig ├── .ember-cli ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── .travis.yml ├── .watchmanconfig ├── CHANGELOG.md ├── LICENSE ├── README.md ├── addon-test-support ├── ember-mocha │ ├── index.js │ ├── setup-application-test.js │ ├── setup-rendering-test.js │ ├── setup-test.js │ └── test-loader.js └── mocha │ └── index.js ├── blueprints └── ember-mocha │ ├── files │ └── tests │ │ └── test-helper.js │ └── index.js ├── config ├── ember-try.js └── environment.js ├── docs ├── legacy.md └── migration.md ├── ember-cli-build.js ├── index.js ├── package.json ├── testem.js ├── tests ├── .eslintrc.js ├── acceptance │ └── setup-application-test-test.js ├── dummy │ ├── app │ │ ├── app.js │ │ ├── index.html │ │ ├── resolver.js │ │ ├── router.js │ │ ├── styles │ │ │ └── app.css │ │ └── templates │ │ │ ├── foo.hbs │ │ │ └── index.hbs │ ├── config │ │ ├── environment.js │ │ └── targets.js │ └── public │ │ ├── crossdomain.xml │ │ └── robots.txt ├── helpers │ ├── destroy-app.js │ ├── grep-for.js │ ├── resolver.js │ └── start-app.js ├── index.html ├── test-helper.js └── unit │ ├── it-test.js │ ├── setup-rendering-test-test.js │ ├── setup-test-test.js │ └── shims-test.js ├── vendor └── ember-mocha │ ├── mocha-configuration.js │ └── test-container-styles.css └── yarn.lock /.dependabot/config.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | update_configs: 3 | - package_manager: "javascript" 4 | directory: "/" 5 | update_schedule: "weekly" 6 | automerged_updates: 7 | - match: 8 | dependency_type: "all" 9 | update_type: "in_range" 10 | version_requirement_updates: "increase_versions" 11 | commit_message: 12 | prefix: "" 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | 8 | [*] 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | indent_style = space 14 | indent_size = 2 15 | 16 | [*.hbs] 17 | insert_final_newline = false 18 | 19 | [*.{diff,md}] 20 | trim_trailing_whitespace = false 21 | -------------------------------------------------------------------------------- /.ember-cli: -------------------------------------------------------------------------------- 1 | { 2 | /** 3 | Ember CLI sends analytics information by default. The data is completely 4 | anonymous, but there are times when you might want to disable this behavior. 5 | 6 | Setting `disableAnalytics` to true will prevent any data from being sent. 7 | */ 8 | "disableAnalytics": false 9 | } 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # unconventional js 2 | /blueprints/*/files/ 3 | /vendor/ 4 | 5 | # compiled output 6 | /dist/ 7 | /tmp/ 8 | 9 | # dependencies 10 | /bower_components/ 11 | /node_modules/ 12 | 13 | # misc 14 | /coverage/ 15 | !.* 16 | 17 | # ember-try 18 | /.node_modules.ember-try/ 19 | /bower.json.ember-try 20 | /package.json.ember-try 21 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parserOptions: { 4 | ecmaVersion: 2017, 5 | sourceType: 'module' 6 | }, 7 | plugins: [ 8 | 'ember' 9 | ], 10 | extends: [ 11 | 'eslint:recommended', 12 | 'plugin:ember/recommended' 13 | ], 14 | env: { 15 | browser: true 16 | }, 17 | rules: { 18 | 'ember/new-module-imports': 'off', 19 | 'ember/no-restricted-resolver-tests': 'off', 20 | }, 21 | overrides: [ 22 | // node files 23 | { 24 | files: [ 25 | '.eslintrc.js', 26 | '.template-lintrc.js', 27 | 'ember-cli-build.js', 28 | 'index.js', 29 | 'testem.js', 30 | 'blueprints/*/index.js', 31 | 'config/**/*.js', 32 | 'tests/dummy/config/**/*.js' 33 | ], 34 | excludedFiles: [ 35 | 'addon/**', 36 | 'addon-test-support/**', 37 | 'app/**', 38 | 'tests/dummy/app/**' 39 | ], 40 | parserOptions: { 41 | sourceType: 'script', 42 | ecmaVersion: 2015 43 | }, 44 | env: { 45 | browser: false, 46 | node: true 47 | }, 48 | plugins: ['node'], 49 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, { 50 | // add your custom rules and overrides for node files here 51 | }) 52 | } 53 | ] 54 | }; 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # compiled output 4 | /dist 5 | /tmp 6 | *.tgz 7 | 8 | # dependencies 9 | /node_modules 10 | /bower_components 11 | 12 | # misc 13 | /.eslintcache 14 | /.sass-cache 15 | /connect.lock 16 | /coverage/* 17 | /libpeerconnection.log 18 | npm-debug.log* 19 | yarn-error.log 20 | testem.log 21 | 22 | # ember-try 23 | .node_modules.ember-try/ 24 | bower.json.ember-try 25 | package.json.ember-try 26 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /config/ember-try.js 2 | /dist 3 | /tests 4 | /tmp 5 | **/.gitkeep 6 | .* 7 | *.tgz 8 | ember-cli-build.js 9 | testem.js 10 | yarn.lock 11 | yarn-error.log 12 | 13 | # ember-try 14 | .node_modules.ember-try/ 15 | package.json.ember-try 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: node_js 3 | node_js: 4 | # we recommend testing addons with the same minimum supported node version as Ember CLI 5 | # so that your addon works for all apps 6 | - "8" 7 | 8 | branches: 9 | except: 10 | - /^dependabot\/.*$/ 11 | 12 | addons: 13 | chrome: stable 14 | 15 | cache: 16 | yarn: true 17 | 18 | env: 19 | global: 20 | # See https://git.io/vdao3 for details. 21 | - JOBS=1 22 | - DEBUG="auto-dist-tag" 23 | matrix: 24 | # we recommend new addons test the current and previous LTS 25 | # as well as latest stable release (bonus points to beta/canary) 26 | - EMBER_TRY_SCENARIO=ember-lts-3.4 27 | - EMBER_TRY_SCENARIO=ember-lts-3.8 28 | - EMBER_TRY_SCENARIO=ember-release 29 | - EMBER_TRY_SCENARIO=ember-beta 30 | - EMBER_TRY_SCENARIO=ember-canary 31 | - EMBER_TRY_SCENARIO=ember-default 32 | 33 | matrix: 34 | fast_finish: true 35 | allow_failures: 36 | - env: EMBER_TRY_SCENARIO=ember-canary 37 | 38 | before_install: 39 | - curl -o- -L https://yarnpkg.com/install.sh | bash 40 | - export PATH=$HOME/.yarn/bin:$PATH 41 | 42 | install: 43 | - yarn install --no-lockfile --non-interactive 44 | 45 | script: 46 | - yarn lint 47 | - yarn ember try:one $EMBER_TRY_SCENARIO 48 | 49 | before_deploy: 50 | - yarn global add auto-dist-tag@0.1 51 | - auto-dist-tag --write 52 | 53 | deploy: 54 | - provider: npm 55 | email: stefan.penner+ember-cli@gmail.com 56 | api_key: 57 | secure: PQRsq4JcFYPXOqov1jwPw63WnwYYpyKby/2akUjq8PHwwgCDEt34Z8yqQdJogqKmKRjijsiWu+b54fbIpZ6TMvqPL18F8FbCl6e2zoAY55VUmmVkx9wkvuPydTDs2fuPqk6LFvmIMiq+pjEPlSeWg3GpFSkFjfs0WZlO33xMyWw= 58 | skip_cleanup: true 59 | on: 60 | tags: true 61 | repo: emberjs/ember-mocha 62 | -------------------------------------------------------------------------------- /.watchmanconfig: -------------------------------------------------------------------------------- 1 | { 2 | "ignore_dirs": ["tmp", "dist"] 3 | } 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v0.16.2 (2019-11-23) 4 | 5 | #### :rocket: Enhancement 6 | * [#459](https://github.com/emberjs/ember-mocha/pull/459) Prevent leakage of position fixed elements from the testing container ([@nickschot](https://github.com/nickschot)) 7 | 8 | #### :bug: Bug Fix 9 | * [#462](https://github.com/emberjs/ember-mocha/pull/462) Fix compatibility with Ember 3.13+ ([@kobsy](https://github.com/kobsy)) 10 | 11 | #### :house: Internal 12 | * [#487](https://github.com/emberjs/ember-mocha/pull/487) Add dependabot configuration file ([@Turbo87](https://github.com/Turbo87)) 13 | 14 | #### Committers: 3 15 | - Matt Kobs ([@kobsy](https://github.com/kobsy)) 16 | - Nick Schot ([@nickschot](https://github.com/nickschot)) 17 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 18 | 19 | 20 | ## v0.16.1 (2019-10-08) 21 | 22 | #### :rocket: Enhancement 23 | * [#456](https://github.com/emberjs/ember-mocha/pull/456) Remove check for ember-cli-htmlbars-inline-precompile ([@richard-viney](https://github.com/richard-viney)) 24 | 25 | #### Committers: 1 26 | - Richard Viney ([@richard-viney](https://github.com/richard-viney)) 27 | 28 | 29 | ## v0.16.0 (2019-06-16) 30 | 31 | #### :boom: Breaking Change 32 | * [#370](https://github.com/emberjs/ember-mocha/pull/370) Drop support for Ember.js v3.3 and below ([@Turbo87](https://github.com/Turbo87)) 33 | * [#369](https://github.com/emberjs/ember-mocha/pull/369) Remove implicit async test helpers support ([@Turbo87](https://github.com/Turbo87)) 34 | * [#368](https://github.com/emberjs/ember-mocha/pull/368) Remove deprecated `setup*Test()` APIs ([@Turbo87](https://github.com/Turbo87)) 35 | * [#367](https://github.com/emberjs/ember-mocha/pull/367) Remove deprecated `describe*()` APIs ([@Turbo87](https://github.com/Turbo87)) 36 | * [#365](https://github.com/emberjs/ember-mocha/pull/365) Drop support for Node.js 6 ([@Turbo87](https://github.com/Turbo87)) 37 | * [#346](https://github.com/emberjs/ember-mocha/pull/346) Bump ember-cli-babel from 6.17.2 to 7.7.3 38 | 39 | #### :memo: Documentation 40 | * [#375](https://github.com/emberjs/ember-mocha/pull/375) Ensure start call is documented in README ([@maxfierke](https://github.com/maxfierke)) 41 | 42 | #### :house: Internal 43 | * [#364](https://github.com/emberjs/ember-mocha/pull/364) Update `.npmignore` file ([@Turbo87](https://github.com/Turbo87)) 44 | 45 | #### Committers: 2 46 | - Max Fierke ([@maxfierke](https://github.com/maxfierke)) 47 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 48 | 49 | 50 | ## v0.15.1 (2019-05-11) 51 | 52 | #### :rocket: Enhancement 53 | * [#366](https://github.com/emberjs/ember-mocha/pull/366) Deprecate `setupTest()`, `setupComponentTest()`, `setupModelTest()` and `setupAcceptanceTest()` functions ([@Turbo87](https://github.com/Turbo87)) 54 | 55 | #### :house: Internal 56 | * [#364](https://github.com/emberjs/ember-mocha/pull/364) Update `.npmignore` file ([@Turbo87](https://github.com/Turbo87)) 57 | 58 | #### Committers: 1 59 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 60 | 61 | 62 | ## v0.15.0 (2019-05-11) 63 | 64 | #### :boom: Breaking Change 65 | * [#281](https://github.com/emberjs/ember-mocha/pull/281) Replace automatic test start via timeout with explicit `start()` call ([@Turbo87](https://github.com/Turbo87)) 66 | * [#219](https://github.com/emberjs/ember-mocha/pull/219) Drop Node 4 support ([@Turbo87](https://github.com/Turbo87)) 67 | 68 | #### :rocket: Enhancement 69 | * [#332](https://github.com/emberjs/ember-mocha/pull/332) Update `@ember/test-helpers` to v1.5.0 70 | * [#310](https://github.com/emberjs/ember-mocha/pull/310) Add `resetOnerror()` from `@ember/test-helpers` ([@scalvert](https://github.com/scalvert)) 71 | * [#280](https://github.com/emberjs/ember-mocha/pull/280) Add `ember-mocha` Blueprint ([@Turbo87](https://github.com/Turbo87)) 72 | * [#222](https://github.com/emberjs/ember-mocha/pull/222) Update minimum version of `@ember/test-helpers` to 0.7.26. ([@rwjblue](https://github.com/rwjblue)) 73 | 74 | #### Committers: 3 75 | - Robert Jackson ([@rwjblue](https://github.com/rwjblue)) 76 | - Steve Calvert ([@scalvert](https://github.com/scalvert)) 77 | - Tobias Bieniek ([@Turbo87](https://github.com/Turbo87)) 78 | 79 | 80 | ## v0.14.0 (2018-06-05) 81 | 82 | #### :rocket: Enhancement 83 | * [#190](https://github.com/emberjs/ember-mocha/pull/190) Add support for new RFC268 based testing API. ([@simonihmig](https://github.com/simonihmig)) 84 | * [#191](https://github.com/emberjs/ember-mocha/pull/191) Remove jQuery dependency. ([@simonihmig](https://github.com/simonihmig)) 85 | * [#192](https://github.com/emberjs/ember-mocha/pull/192) Add hooks API for setupContainerTest() to improve beforeEach/afterEach ordering. ([@simonihmig](https://github.com/simonihmig)) 86 | * [#194](https://github.com/emberjs/ember-mocha/pull/194) Remove mochaRunner global assignment to prevent memory leaks. ([@simonihmig](https://github.com/simonihmig)) 87 | 88 | #### :memo: Documentation 89 | * [#200](https://github.com/emberjs/ember-mocha/pull/200) Update documentation for new APIs. ([@simonihmig](https://github.com/simonihmig)) 90 | * [#201](https://github.com/emberjs/ember-mocha/pull/201) Adjust documentation. ([@Turbo87](https://github.com/Turbo87)) 91 | * [#202](https://github.com/emberjs/ember-mocha/pull/202) Fix migration guide. ([@simonihmig](https://github.com/simonihmig)) 92 | * [#204](https://github.com/emberjs/ember-mocha/pull/204) Add mention of `this.on` to migration guide. ([@alexlafroscia](https://github.com/alexlafroscia)) 93 | 94 | #### :house: Internal 95 | * [#195](https://github.com/emberjs/ember-mocha/pull/195) Extract `setupPauseTest()` function. ([@Turbo87](https://github.com/Turbo87)) 96 | * [#193](https://github.com/emberjs/ember-mocha/pull/193) Simplify `chainHooks()` function. ([@Turbo87](https://github.com/Turbo87)) 97 | * [#189](https://github.com/emberjs/ember-mocha/pull/189) Updating the @ember/test-helpers. ([@josh803316](https://github.com/josh803316)) 98 | 99 | #### Committers: 4 100 | - Alex LaFroscia ([alexlafroscia](https://github.com/alexlafroscia)) 101 | - Josh Nisenson ([josh803316](https://github.com/josh803316)) 102 | - Simon Ihmig ([simonihmig](https://github.com/simonihmig)) 103 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 104 | 105 | 106 | ## v0.13.1 (2018-02-05) 107 | 108 | #### :bug: Bug Fix 109 | * [#188](https://github.com/emberjs/ember-mocha/pull/188) Adjust import paths for `getContext()` and `setResolver()`. ([@Turbo87](https://github.com/Turbo87)) 110 | 111 | #### :house: Internal 112 | * [#187](https://github.com/emberjs/ember-mocha/pull/187) CI: Remove `--skip-cleanup` from `try:one` command. ([@Turbo87](https://github.com/Turbo87)) 113 | 114 | #### Committers: 1 115 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 116 | 117 | 118 | ## v0.13.0 (2018-02-03) 119 | 120 | #### :boom: Breaking Change 121 | * [#173](https://github.com/emberjs/ember-mocha/pull/173) Convert to Ember CLI addon. ([@Turbo87](https://github.com/Turbo87)) 122 | 123 | #### :rocket: Enhancement 124 | * [#186](https://github.com/emberjs/ember-mocha/pull/186) Update `@ember/test-helpers` to v0.7.16. ([@Turbo87](https://github.com/Turbo87)) 125 | * [#180](https://github.com/emberjs/ember-mocha/pull/180) Update `@ember/test-helpers` to v0.7.10. ([@Turbo87](https://github.com/Turbo87)) 126 | 127 | #### :bug: Bug Fix 128 | * [#183](https://github.com/emberjs/ember-mocha/pull/183) Add missing `overrideTestCommandFilter()` method. ([@Turbo87](https://github.com/Turbo87)) 129 | * [#179](https://github.com/emberjs/ember-mocha/pull/179) Update `@ember/test-helpers` to v0.7.5. ([@Turbo87](https://github.com/Turbo87)) 130 | * [#178](https://github.com/emberjs/ember-mocha/pull/178) Update `@ember/test-helpers` to v0.7.4. ([@Turbo87](https://github.com/Turbo87)) 131 | 132 | #### :memo: Documentation 133 | * [#175](https://github.com/emberjs/ember-mocha/pull/175) Use `lerna-changelog` to generate friendly changelog. ([@Turbo87](https://github.com/Turbo87)) 134 | 135 | #### :house: Internal 136 | * [#185](https://github.com/emberjs/ember-mocha/pull/185) CI: Use `skip_cleanup` to fix `auto-dist-tag` behavior. ([@Turbo87](https://github.com/Turbo87)) 137 | * [#184](https://github.com/emberjs/ember-mocha/pull/184) testem: Use `--no-sandbox` on TravisCI. ([@Turbo87](https://github.com/Turbo87)) 138 | * [#181](https://github.com/emberjs/ember-mocha/pull/181) CI: Run `auto-dist-tag` in DEBUG mode. ([@Turbo87](https://github.com/Turbo87)) 139 | * [#174](https://github.com/emberjs/ember-mocha/pull/174) CI: Add Ember 2.0, 2.4 and 2.8 as test targets. ([@Turbo87](https://github.com/Turbo87)) 140 | * [#172](https://github.com/emberjs/ember-mocha/pull/172) Update `broccoli-lint-eslint` and use `group` option. ([@Turbo87](https://github.com/Turbo87)) 141 | * [#171](https://github.com/emberjs/ember-mocha/pull/171) Remove `bower` publishing code. ([@Turbo87](https://github.com/Turbo87)) 142 | * [#170](https://github.com/emberjs/ember-mocha/pull/170) Use headless Chrome instead of PhantomJS. ([@Turbo87](https://github.com/Turbo87)) 143 | * [#169](https://github.com/emberjs/ember-mocha/pull/169) Add yarn lockfile and use yarn for CI. ([@Turbo87](https://github.com/Turbo87)) 144 | 145 | #### Committers: 1 146 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 147 | 148 | 149 | ## v0.13.0-beta.4 (2018-02-03) 150 | 151 | #### :bug: Bug Fix 152 | * [#183](https://github.com/emberjs/ember-mocha/pull/183) Add missing `overrideTestCommandFilter()` method. ([@Turbo87](https://github.com/Turbo87)) 153 | 154 | #### :house: Internal 155 | * [#184](https://github.com/emberjs/ember-mocha/pull/184) testem: Use `--no-sandbox` on TravisCI. ([@Turbo87](https://github.com/Turbo87)) 156 | 157 | #### Committers: 1 158 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 159 | 160 | 161 | ## v0.13.0-beta.3 (2017-12-22) 162 | 163 | #### :rocket: Enhancement 164 | * [#180](https://github.com/emberjs/ember-mocha/pull/180) Update `@ember/test-helpers` to v0.7.10. ([@Turbo87](https://github.com/Turbo87)) 165 | 166 | #### :house: Internal 167 | * [#181](https://github.com/emberjs/ember-mocha/pull/181) CI: Run `auto-dist-tag` in DEBUG mode. ([@Turbo87](https://github.com/Turbo87)) 168 | 169 | #### Committers: 1 170 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 171 | 172 | 173 | ## v0.13.0-beta.2 (2017-12-15) 174 | 175 | #### :bug: Bug Fix 176 | * [#179](https://github.com/emberjs/ember-mocha/pull/179) Update `@ember/test-helpers` to v0.7.5. ([@Turbo87](https://github.com/Turbo87)) 177 | * [#178](https://github.com/emberjs/ember-mocha/pull/178) Update `@ember/test-helpers` to v0.7.4. ([@Turbo87](https://github.com/Turbo87)) 178 | 179 | #### Committers: 1 180 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 181 | 182 | 183 | ## v0.13.0-beta.1 (2017-12-06) 184 | 185 | #### :boom: Breaking Change 186 | * [#173](https://github.com/emberjs/ember-mocha/pull/173) Convert to Ember CLI addon. ([@Turbo87](https://github.com/Turbo87)) 187 | 188 | #### :memo: Documentation 189 | * [#175](https://github.com/emberjs/ember-mocha/pull/175) Use `lerna-changelog` to generate friendly changelog. ([@Turbo87](https://github.com/Turbo87)) 190 | 191 | #### :house: Internal 192 | * [#174](https://github.com/emberjs/ember-mocha/pull/174) CI: Add Ember 2.0, 2.4 and 2.8 as test targets. ([@Turbo87](https://github.com/Turbo87)) 193 | * [#172](https://github.com/emberjs/ember-mocha/pull/172) Update `broccoli-lint-eslint` and use `group` option. ([@Turbo87](https://github.com/Turbo87)) 194 | * [#171](https://github.com/emberjs/ember-mocha/pull/171) Remove `bower` publishing code. ([@Turbo87](https://github.com/Turbo87)) 195 | * [#170](https://github.com/emberjs/ember-mocha/pull/170) Use headless Chrome instead of PhantomJS. ([@Turbo87](https://github.com/Turbo87)) 196 | * [#169](https://github.com/emberjs/ember-mocha/pull/169) Add yarn lockfile and use yarn for CI. ([@Turbo87](https://github.com/Turbo87)) 197 | 198 | #### Committers: 2 199 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 200 | 201 | 202 | ## v0.12.0 (2017-05-26) 203 | 204 | #### :rocket: Enhancement 205 | * [#123](https://github.com/emberjs/ember-mocha/pull/123) Improved async behavior deprecation message. ([@Turbo87](https://github.com/Turbo87)) 206 | * [#124](https://github.com/emberjs/ember-mocha/pull/124) README: Add instructions for a world with async/await. ([@Turbo87](https://github.com/Turbo87)) 207 | 208 | #### :bug: Bug Fix 209 | * [#156](https://github.com/emberjs/ember-mocha/pull/156) Fix "rollup-plugin-alias" options. ([@Turbo87](https://github.com/Turbo87)) 210 | 211 | #### :house: Internal 212 | * [#128](https://github.com/emberjs/ember-mocha/pull/128) Ensure ember-test-helpers ^0.6.0. ([@blimmer](https://github.com/blimmer)) 213 | * [#125](https://github.com/emberjs/ember-mocha/pull/125) CI: Switch NPM deploy user to "ember-cli". ([@Turbo87](https://github.com/Turbo87)) 214 | * [#117](https://github.com/emberjs/ember-mocha/pull/117) Use Rollup to bundle files. ([@Turbo87](https://github.com/Turbo87)) 215 | 216 | #### Committers: 2 217 | - Ben Limmer ([blimmer](https://github.com/blimmer)) 218 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 219 | 220 | 221 | ## v0.11.1 (2017-05-07) 222 | 223 | #### :bug: Bug Fix 224 | * [#150](https://github.com/emberjs/ember-mocha/pull/150) Update "ember-test-helpers" to v0.6.3. ([@Turbo87](https://github.com/Turbo87)) 225 | * [#144](https://github.com/emberjs/ember-mocha/pull/144) Reset "module" to null to prevent memory leaks. ([@Turbo87](https://github.com/Turbo87)) 226 | * [#146](https://github.com/emberjs/ember-mocha/pull/146) Update and pin "loader.js" to v4.1.0. ([@Turbo87](https://github.com/Turbo87)) 227 | 228 | #### :house: Internal 229 | * [#147](https://github.com/emberjs/ember-mocha/pull/147) Convert "loader.js" from bower to npm dependency. ([@Turbo87](https://github.com/Turbo87)) 230 | 231 | #### Committers: 1 232 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 233 | 234 | 235 | ## v0.11.0 (2016-12-09) 236 | 237 | #### :rocket: Enhancement 238 | * [#122](https://github.com/emberjs/ember-mocha/pull/122) Update "mocha" and "chai" bower dependencies. ([@Turbo87](https://github.com/Turbo87)) 239 | * [#120](https://github.com/emberjs/ember-mocha/pull/120) Import "ember-mocha-adapter". ([@Turbo87](https://github.com/Turbo87)) 240 | * [#119](https://github.com/emberjs/ember-mocha/pull/119) Adjust testem config and add acceptance test. ([@Turbo87](https://github.com/Turbo87)) 241 | * [#118](https://github.com/emberjs/ember-mocha/pull/118) TravisCI: Update Node.js to 6.x. ([@Turbo87](https://github.com/Turbo87)) 242 | 243 | #### Committers: 1 244 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 245 | 246 | 247 | ## v0.10.0 (2016-11-29) 248 | 249 | #### :house: Internal 250 | * [#114](https://github.com/emberjs/ember-mocha/pull/114) Update "ember-test-helpers" to v0.6.0-beta.1. ([@Turbo87](https://github.com/Turbo87)) 251 | 252 | #### Committers: 1 253 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 254 | 255 | 256 | ## v0.9.4 (2016-11-27) 257 | 258 | #### :rocket: Enhancement 259 | * [#105](https://github.com/emberjs/ember-mocha/pull/105) CI: Publish tags to NPM. ([@Turbo87](https://github.com/Turbo87)) 260 | 261 | #### :bug: Bug Fix 262 | * [#111](https://github.com/emberjs/ember-mocha/pull/111) Fix broken context cleanup. ([@Turbo87](https://github.com/Turbo87)) 263 | * [#102](https://github.com/emberjs/ember-mocha/pull/102) Export new test setup functions as globals. ([@Turbo87](https://github.com/Turbo87)) 264 | 265 | #### :house: Internal 266 | * [#109](https://github.com/emberjs/ember-mocha/pull/109) Remove "chai" vendor shim. ([@Turbo87](https://github.com/Turbo87)) 267 | 268 | #### Committers: 1 269 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 270 | 271 | 272 | ## v0.9.3 (2016-11-23) 273 | 274 | #### :rocket: Enhancement 275 | * [#108](https://github.com/emberjs/ember-mocha/pull/108) mocha-module: Add upgrade guide URL to the deprecation message. ([@Turbo87](https://github.com/Turbo87)) 276 | * [#107](https://github.com/emberjs/ember-mocha/pull/107) package.json: Add "files" section. ([@Turbo87](https://github.com/Turbo87)) 277 | 278 | #### Committers: 1 279 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 280 | 281 | 282 | ## v0.9.2 (2016-11-23) 283 | 284 | #### :rocket: Enhancement 285 | * [#106](https://github.com/emberjs/ember-mocha/pull/106) Add "Upgrade Guide" to the README. ([@Turbo87](https://github.com/Turbo87)) 286 | * [#100](https://github.com/emberjs/ember-mocha/pull/100) CI: Publish releases to "ember-mocha-builds" repo. ([@Turbo87](https://github.com/Turbo87)) 287 | 288 | #### :bug: Bug Fix 289 | * [#101](https://github.com/emberjs/ember-mocha/pull/101) Fix tests by using the ESLint nodes correctly. ([@Turbo87](https://github.com/Turbo87)) 290 | 291 | #### :memo: Documentation 292 | * [#96](https://github.com/emberjs/ember-mocha/pull/96) Update CHANGELOG. ([@Turbo87](https://github.com/Turbo87)) 293 | * [#97](https://github.com/emberjs/ember-mocha/pull/97) Update README. ([@Turbo87](https://github.com/Turbo87)) 294 | 295 | #### :house: Internal 296 | * [#94](https://github.com/emberjs/ember-mocha/pull/94) Cleanup package.json. ([@Turbo87](https://github.com/Turbo87)) 297 | 298 | #### Committers: 1 299 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 300 | 301 | 302 | ## v0.9.1 (2016-09-12) 303 | 304 | #### :house: Internal 305 | * [#91](https://github.com/emberjs/ember-mocha/pull/91) Share Mocha's test context in setup-test-factory.. ([@dgeb](https://github.com/dgeb)) 306 | 307 | #### Committers: 1 308 | - Dan Gebhardt ([dgeb](https://github.com/dgeb)) 309 | 310 | 311 | ## v0.9.0 (2016-09-12) 312 | 313 | #### :rocket: Enhancement 314 | * [#84](https://github.com/emberjs/ember-mocha/pull/84) New testing API. ([@Turbo87](https://github.com/Turbo87)) 315 | * [#76](https://github.com/emberjs/ember-mocha/pull/76) Adjust "mocha" dependency to allow 2.3, 2.4, ... releases. ([@Turbo87](https://github.com/Turbo87)) 316 | 317 | #### :memo: Documentation 318 | * [#86](https://github.com/emberjs/ember-mocha/pull/86) Add changelog file. ([@Turbo87](https://github.com/Turbo87)) 319 | 320 | #### :house: Internal 321 | * [#90](https://github.com/emberjs/ember-mocha/pull/90) Preserve suite context in outer test function. ([@dgeb](https://github.com/dgeb)) 322 | * [#89](https://github.com/emberjs/ember-mocha/pull/89) Share Mocha's test context.. ([@dgeb](https://github.com/dgeb)) 323 | * [#88](https://github.com/emberjs/ember-mocha/pull/88) Use predefined ESLint test generator. ([@Turbo87](https://github.com/Turbo87)) 324 | * [#85](https://github.com/emberjs/ember-mocha/pull/85) Replace JSHint with ESLint. ([@Turbo87](https://github.com/Turbo87)) 325 | * [#83](https://github.com/emberjs/ember-mocha/pull/83) Update NPM dependencies. ([@Turbo87](https://github.com/Turbo87)) 326 | 327 | #### Committers: 2 328 | - Dan Gebhardt ([dgeb](https://github.com/dgeb)) 329 | - Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) 330 | 331 | 332 | ## v0.8.1 (2016-02-01) 333 | 334 | #### :rocket: Enhancement 335 | * [#47](https://github.com/emberjs/ember-mocha/pull/47) Update ember test helpers for Ember 2.0.0-beta.3.. ([@Robdel12](https://github.com/Robdel12)) 336 | * [#43](https://github.com/emberjs/ember-mocha/pull/43) Update ember-test-helpers. ([@sly7-7](https://github.com/sly7-7)) 337 | 338 | #### :bug: Bug Fix 339 | * [#72](https://github.com/emberjs/ember-mocha/pull/72) Ensure builds of ember-test-helpers are properly transpiled.. ([@rwjblue](https://github.com/rwjblue)) 340 | * [#48](https://github.com/emberjs/ember-mocha/pull/48) remove resetViews from 'it'. ([@jeffreybiles](https://github.com/jeffreybiles)) 341 | 342 | #### :house: Internal 343 | * [#45](https://github.com/emberjs/ember-mocha/pull/45) Remove usage of deprecated `Ember.keys`. ([@tstirrat](https://github.com/tstirrat)) 344 | 345 | #### Committers: 5 346 | - Jeffrey Biles ([jeffreybiles](https://github.com/jeffreybiles)) 347 | - Robert DeLuca ([Robdel12](https://github.com/Robdel12)) 348 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 349 | - Sylvain MINA ([sly7-7](https://github.com/sly7-7)) 350 | - Tim Stirrat ([tstirrat](https://github.com/tstirrat)) 351 | 352 | 353 | ## v0.8.10 (2016-02-01) 354 | 355 | #### :bug: Bug Fix 356 | * [#72](https://github.com/emberjs/ember-mocha/pull/72) Ensure builds of ember-test-helpers are properly transpiled.. ([@rwjblue](https://github.com/rwjblue)) 357 | 358 | #### Committers: 1 359 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 360 | 361 | 362 | ## v0.8.6 (2015-10-27) 363 | 364 | #### :rocket: Enhancement 365 | * [#65](https://github.com/emberjs/ember-mocha/pull/65) Expose chai configuration object. ([@mupkoo](https://github.com/mupkoo)) 366 | 367 | #### Committers: 1 368 | - Mirko Akov ([mupkoo](https://github.com/mupkoo)) 369 | 370 | 371 | ## v0.8.4 (2015-10-02) 372 | 373 | #### :rocket: Enhancement 374 | * [#62](https://github.com/emberjs/ember-mocha/pull/62) Update ember-test-helpers to 0.5.11. ([@mattmcmanus](https://github.com/mattmcmanus)) 375 | * [#59](https://github.com/emberjs/ember-mocha/pull/59) Add shim for context. ([@SaladFork](https://github.com/SaladFork)) 376 | 377 | #### Committers: 2 378 | - Elad Shahar ([SaladFork](https://github.com/SaladFork)) 379 | - Matt McManus ([mattmcmanus](https://github.com/mattmcmanus)) 380 | 381 | 382 | ## v0.8.3 (2015-09-13) 383 | 384 | #### :rocket: Enhancement 385 | * [#58](https://github.com/emberjs/ember-mocha/pull/58) Update minimum version of ember-test-helpers.. ([@rwjblue](https://github.com/rwjblue)) 386 | * [#57](https://github.com/emberjs/ember-mocha/pull/57) Make `beforeEach` and `afterEach` use Ember.run. ([@cowboyd](https://github.com/cowboyd)) 387 | 388 | #### Committers: 2 389 | - Charles Lowell ([cowboyd](https://github.com/cowboyd)) 390 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 391 | 392 | 393 | ## v0.8.2 (2015-08-27) 394 | 395 | #### :rocket: Enhancement 396 | * [#55](https://github.com/emberjs/ember-mocha/pull/55) Update ember-test-helpers minimum version.. ([@rwjblue](https://github.com/rwjblue)) 397 | 398 | #### Committers: 1 399 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 400 | 401 | 402 | ## v0.8.0 (2015-06-19) 403 | 404 | #### :rocket: Enhancement 405 | * [#39](https://github.com/emberjs/ember-mocha/pull/39) Update ember-test-helpers to 0.5.0.. ([@eriktrom](https://github.com/eriktrom)) 406 | 407 | #### Committers: 1 408 | - Erik Trom ([eriktrom](https://github.com/eriktrom)) 409 | 410 | 411 | ## v0.6.3 (2015-05-13) 412 | 413 | #### :rocket: Enhancement 414 | * [#35](https://github.com/emberjs/ember-mocha/pull/35) Bump ember-test-helpers, mocha, and chai. ([@dgeb](https://github.com/dgeb)) 415 | 416 | #### Committers: 1 417 | - Dan Gebhardt ([dgeb](https://github.com/dgeb)) 418 | 419 | 420 | ## v0.6.1 (2015-04-04) 421 | 422 | #### :rocket: Enhancement 423 | * [#32](https://github.com/emberjs/ember-mocha/pull/32) Update to use newer ember-mocha-adapter. ([@ef4](https://github.com/ef4)) 424 | 425 | #### Committers: 1 426 | - Edward Faulkner ([ef4](https://github.com/ef4)) 427 | 428 | 429 | ## v0.6.0 (2015-03-24) 430 | 431 | #### :rocket: Enhancement 432 | * [#27](https://github.com/emberjs/ember-mocha/pull/27) Expose Chai helpers for custom assertions. ([@dfreeman](https://github.com/dfreeman)) 433 | * [#29](https://github.com/emberjs/ember-mocha/pull/29) Update ember-test-helpers. ([@dfreeman](https://github.com/dfreeman)) 434 | 435 | #### Committers: 1 436 | - Dan Freeman ([dfreeman](https://github.com/dfreeman)) 437 | 438 | 439 | ## v0.4.4 (2015-02-22) 440 | 441 | #### :rocket: Enhancement 442 | * [#23](https://github.com/emberjs/ember-mocha/pull/23) Add chai and mocha ES6 shims.. ([@rwjblue](https://github.com/rwjblue)) 443 | 444 | #### Committers: 1 445 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 446 | 447 | 448 | ## v0.4.1 (2015-02-08) 449 | 450 | #### :house: Internal 451 | * [#20](https://github.com/emberjs/ember-mocha/pull/20) Switch from broccoli-cli to ember-cli.. ([@dgeb](https://github.com/dgeb)) 452 | * [#18](https://github.com/emberjs/ember-mocha/pull/18) Use git-repo-version instead of git-repo-info directly.. ([@dgeb](https://github.com/dgeb)) 453 | * [#19](https://github.com/emberjs/ember-mocha/pull/19) Upgrade ember to 1.10.0 and remove handlebars.. ([@dgeb](https://github.com/dgeb)) 454 | 455 | #### Committers: 1 456 | - Dan Gebhardt ([dgeb](https://github.com/dgeb)) 457 | 458 | 459 | ## v0.2.2 (2015-01-25) 460 | 461 | #### :house: Internal 462 | * [#12](https://github.com/emberjs/ember-mocha/pull/12) Add broccoli-cli for running tests. ([@backspace](https://github.com/backspace)) 463 | 464 | #### Committers: 1 465 | - Buck Doyle ([backspace](https://github.com/backspace)) 466 | 467 | 468 | ## v0.2.1 (2014-12-11) 469 | 470 | #### :rocket: Enhancement 471 | * [#9](https://github.com/emberjs/ember-mocha/pull/9) toString method of wrapper of it should forward to callback.toString ins.... ([@lyonlai](https://github.com/lyonlai)) 472 | 473 | #### Committers: 1 474 | - Yun Lai ([lyonlai](https://github.com/lyonlai)) 475 | 476 | 477 | ## v0.1.3 (2014-11-26) 478 | 479 | #### :rocket: Enhancement 480 | * [#7](https://github.com/emberjs/ember-mocha/pull/7) Add mocha to generated bower.json.. ([@rwjblue](https://github.com/rwjblue)) 481 | 482 | #### Committers: 1 483 | - Robert Jackson ([rwjblue](https://github.com/rwjblue)) 484 | 485 | 486 | ## v0.1.2 (2014-11-26) 487 | 488 | #### :rocket: Enhancement 489 | * [#6](https://github.com/emberjs/ember-mocha/pull/6) preserve mocha test context in both setup and assertion blocks. ([@cowboyd](https://github.com/cowboyd)) 490 | * [#4](https://github.com/emberjs/ember-mocha/pull/4) allow `it`, `xit`, `it.skip` and `it.only` forms.. ([@cowboyd](https://github.com/cowboyd)) 491 | 492 | #### :bug: Bug Fix 493 | * [#5](https://github.com/emberjs/ember-mocha/pull/5) Globalized fixes. ([@cowboyd](https://github.com/cowboyd)) 494 | * [#2](https://github.com/emberjs/ember-mocha/pull/2) call to it caused infinite loop in global build. ([@cowboyd](https://github.com/cowboyd)) 495 | 496 | #### Committers: 1 497 | - Charles Lowell ([cowboyd](https://github.com/cowboyd)) 498 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | DEPRECATION WARNING 2 | =================== 3 | 4 | This package is not actively developed. [ember-qunit](https://github.com/emberjs/ember-qunit) is a good alternative. 5 | 6 | If you use ember-mocha and want to maintain it, please ask in the #help channel on the ember discord. 7 | 8 | ember-mocha 9 | ============================================================================== 10 | 11 | [![Latest NPM release][npm-badge]][npm-badge-url] 12 | [![TravisCI Build Status][travis-badge]][travis-badge-url] 13 | 14 | [npm-badge]: https://img.shields.io/npm/v/ember-mocha.svg 15 | [npm-badge-url]: https://www.npmjs.com/package/ember-mocha 16 | [travis-badge]: https://img.shields.io/travis/emberjs/ember-mocha/master.svg 17 | [travis-badge-url]: https://travis-ci.org/emberjs/ember-mocha 18 | 19 | ember-mocha simplifies testing of Ember applications with 20 | [Mocha](https://mochajs.org/) by providing Mocha-specific wrappers around the 21 | helpers contained in 22 | [@ember/test-helpers](https://github.com/emberjs/ember-test-helpers). 23 | 24 | *Upgrading from an earlier version? Have a look at our 25 | [Migration Guide](docs/migration.md).* 26 | 27 | 28 | Compatibility 29 | ------------------------------------------------------------------------------ 30 | 31 | - Ember.js v3.4 or above 32 | - Ember CLI v2.13 or above 33 | - Node.js 8 or above 34 | 35 | 36 | Installation 37 | ------------------------------------------------------------------------------ 38 | 39 | `ember-mocha` is an [Ember CLI](http://www.ember-cli.com/) addon, so install it 40 | as you would any other addon: 41 | 42 | ```sh 43 | $ ember install ember-mocha 44 | ``` 45 | 46 | Some other addons are detecting the test framework based on the installed 47 | addon names and are expecting `ember-cli-mocha` instead. If you have issues 48 | with this then `ember install ember-cli-mocha`, which should work exactly 49 | the same. 50 | 51 | 52 | Usage 53 | ------------------------------------------------------------------------------ 54 | 55 | The following section describes the use of Ember Mocha with the latest modern 56 | Ember testing APIs, as laid out in the RFCs 57 | [232](https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md) 58 | and 59 | [268](https://github.com/emberjs/rfcs/blob/master/text/0268-acceptance-testing-refactor.md). 60 | 61 | For the older APIs have a look at our [Legacy Guide](docs/legacy.md). 62 | 63 | ### Setting the Application 64 | 65 | Your `tests/test-helper.js` file should look similar to the following, to 66 | correctly setup the application required by `@ember/test-helpers`: 67 | 68 | ```javascript 69 | import Application from '../app'; 70 | import config from '../config/environment'; 71 | import { setApplication } from '@ember/test-helpers'; 72 | import { start } from 'ember-mocha'; 73 | 74 | setApplication(Application.create(config.APP)); 75 | start(); 76 | ``` 77 | 78 | Also make sure that you have set `ENV.APP.autoboot = false;` for the `test` 79 | environment in your `config/environment.js`. 80 | 81 | ### Setup Tests 82 | 83 | The `setupTest()` function can be used to setup a unit test for any kind 84 | of "module/unit" of your application that can be looked up in a container. 85 | 86 | It will setup your test context with: 87 | 88 | * `this.owner` to interact with Ember's [Dependency Injection](https://guides.emberjs.com/v3.0.0/applications/dependency-injection/) 89 | system 90 | * `this.set()`, `this.setProperties()`, `this.get()`, and `this.getProperties()` 91 | * `this.pauseTest()` method to allow easy pausing/resuming of tests 92 | 93 | For example, the following is a unit test for the `SidebarController`: 94 | 95 | ```javascript 96 | import { expect } from 'chai'; 97 | import { describe, it } from 'mocha'; 98 | import { setupTest } from 'ember-mocha'; 99 | 100 | describe('SidebarController', function() { 101 | setupTest(); 102 | 103 | // Replace this with your real tests. 104 | it('exists', function() { 105 | let controller = this.owner.lookup('controller:sidebar'); 106 | expect(controller).to.be.ok; 107 | }); 108 | }); 109 | ``` 110 | 111 | If you find that test helpers from other addons want you to pass a `hooks` 112 | object you can do so like this: 113 | 114 | ```javascript 115 | let hooks = setupTest(); 116 | setupMirage(hooks); 117 | ``` 118 | 119 | This will make sure that in functions passed to `hooks.afterEach()` the 120 | `this.owner` and other things that `setupTest()` sets up are still available. 121 | Mocha itself runs `afterEach` hooks in a different order than QUnit, which is 122 | why this "workaround" is sometimes needed. 123 | 124 | 125 | ### Setup Rendering Tests 126 | 127 | The `setupRenderingTest()` function is specifically designed for tests that 128 | render arbitrary templates, including components and helpers. 129 | 130 | It will setup your test context the same way as `setupTest()`, and additionally: 131 | 132 | * Initializes Ember's renderer to be used with the 133 | [Rendering helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#rendering-helpers), 134 | specifically `render()` 135 | * Adds `this.element` to your test context which returns the DOM element 136 | representing the wrapper around the elements that were rendered via 137 | `render()` 138 | * sets up the [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers) 139 | from `@ember/test-helpers` (`click()`, `fillIn()`, ...) 140 | 141 | ```javascript 142 | import { expect } from 'chai'; 143 | import { describe, it } from 'mocha'; 144 | import { setupRenderingTest } from 'ember-mocha'; 145 | import { render } from '@ember/test-helpers'; 146 | import hbs from 'htmlbars-inline-precompile'; 147 | 148 | describe('GravatarImageComponent', function() { 149 | setupRenderingTest(); 150 | 151 | it('renders', async function() { 152 | await render(hbs`{{gravatar-image}}`); 153 | expect(this.element.querySelector('img')).to.exist; 154 | }); 155 | }); 156 | ``` 157 | 158 | ### Setup Application Tests 159 | 160 | The `setupApplicationTest()` function can be used to run tests that interact 161 | with the whole application, so in most cases acceptance tests. 162 | 163 | On top of `setupTest()` it will: 164 | 165 | * Boot your application instance 166 | * Set up all the [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers) 167 | (`click()`, `fillIn()`, ...) as well as the [Routing Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#routing-helpers) 168 | (`visit()`, `currentURL()`, ...) from `@ember/test-helpers` 169 | 170 | ```javascript 171 | import { expect } from 'chai'; 172 | import { describe, it } from 'mocha'; 173 | import { setupApplicationTest } from 'ember-mocha'; 174 | import { visit, currentURL } from '@ember/test-helpers'; 175 | 176 | describe('basic acceptance test', function() { 177 | setupApplicationTest(); 178 | 179 | it('can visit /', async function() { 180 | await visit('/'); 181 | expect(currentURL()).to.equal('/'); 182 | }); 183 | }); 184 | ``` 185 | 186 | Upgrading 187 | ------------------------------------------------------------------------------ 188 | 189 | For instructions how to upgrade your test suite please read our 190 | [Migration Guide](docs/migration.md). 191 | 192 | Contributing 193 | ------------------------------------------------------------------------------ 194 | 195 | Contributions are welcome. Please follow the instructions below to install and 196 | test this library. 197 | 198 | ### Installation 199 | 200 | ```sh 201 | npm install 202 | ``` 203 | 204 | ### Testing 205 | 206 | In order to test in the browser: 207 | 208 | ```sh 209 | npm start 210 | ``` 211 | 212 | ... and then visit [http://localhost:4200/tests](http://localhost:4200/tests). 213 | 214 | In order to perform a CI test: 215 | 216 | ```sh 217 | npm test 218 | ``` 219 | 220 | 221 | Copyright and License 222 | ------------------------------------------------------------------------------ 223 | 224 | Copyright 2014 Switchfly 225 | 226 | This product includes software developed at 227 | Switchfly (http://www.switchfly.com). 228 | 229 | NOTICE: Only our own original work is licensed under the terms of the Apache 230 | License Version 2.0. The licenses of some libraries might impose different 231 | redistribution or general licensing terms than those stated in the Apache 232 | License. Users and redistributors are hereby requested to verify these 233 | conditions and agree upon them. 234 | -------------------------------------------------------------------------------- /addon-test-support/ember-mocha/index.js: -------------------------------------------------------------------------------- 1 | /* globals mocha */ 2 | 3 | export { loadTests } from './test-loader'; 4 | 5 | import { loadTests } from './test-loader'; 6 | import setupTest from 'ember-mocha/setup-test'; 7 | import setupRenderingTest from 'ember-mocha/setup-rendering-test'; 8 | import setupApplicationTest from 'ember-mocha/setup-application-test'; 9 | import { it, afterEach } from 'mocha'; 10 | import { setResolver, resetOnerror } from '@ember/test-helpers'; 11 | 12 | /** 13 | * Instruct Mocha to start the tests. 14 | */ 15 | export function startTests() { 16 | mocha.run(); 17 | } 18 | 19 | function setupResetOnerror() { 20 | afterEach(function() { 21 | resetOnerror(); 22 | }); 23 | } 24 | 25 | /** 26 | * @method start 27 | * @param {Object} [options] Options to be used for enabling/disabling behaviors 28 | * @param {Boolean} [options.loadTests] If `false` tests will not be loaded automatically. 29 | * @param {Boolean} [options.startTests] If `false` tests will not be automatically started 30 | * (you must run `startTests()` to kick them off). 31 | */ 32 | export function start(options = {}) { 33 | setupResetOnerror(); 34 | 35 | if (options.loadTests !== false) { 36 | loadTests(); 37 | } 38 | 39 | if (options.startTests !== false) { 40 | startTests(); 41 | } 42 | } 43 | 44 | export { 45 | setupTest, 46 | setupRenderingTest, 47 | setupApplicationTest, 48 | it, 49 | setResolver, 50 | }; 51 | -------------------------------------------------------------------------------- /addon-test-support/ember-mocha/setup-application-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | setupApplicationContext, 3 | teardownApplicationContext 4 | } from '@ember/test-helpers'; 5 | import setupTest from './setup-test'; 6 | 7 | export default function setupApplicationTest(options) { 8 | let hooks = setupTest(options); 9 | 10 | hooks.beforeEach(function() { 11 | return setupApplicationContext(this); 12 | }); 13 | hooks.afterEach(function() { 14 | return teardownApplicationContext(this); 15 | }); 16 | 17 | return hooks; 18 | } 19 | -------------------------------------------------------------------------------- /addon-test-support/ember-mocha/setup-rendering-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | setupRenderingContext, 3 | teardownRenderingContext 4 | } from '@ember/test-helpers'; 5 | import setupTest from './setup-test'; 6 | 7 | export default function setupRenderingTest(options) { 8 | let hooks = setupTest(options); 9 | 10 | hooks.beforeEach(function() { 11 | return setupRenderingContext(this); 12 | }); 13 | hooks.afterEach(function() { 14 | return teardownRenderingContext(this); 15 | }); 16 | 17 | return hooks; 18 | } 19 | -------------------------------------------------------------------------------- /addon-test-support/ember-mocha/setup-test.js: -------------------------------------------------------------------------------- 1 | import { 2 | beforeEach, 3 | afterEach 4 | } from 'mocha'; 5 | import { 6 | setupContext, 7 | teardownContext 8 | } from '@ember/test-helpers'; 9 | import { assign, merge } from '@ember/polyfills'; 10 | import { resolve } from 'rsvp'; 11 | import Ember from 'ember'; 12 | 13 | let teardownMandatorySetter; 14 | if (Ember.__loader && Ember.__loader.registry && Ember.__loader.registry['@ember/-internals/utils/index']) { 15 | teardownMandatorySetter = Ember.__loader.require('@ember/-internals/utils').teardownMandatorySetter; 16 | } 17 | 18 | const _assign = assign || merge; 19 | 20 | function chainHooks(hooks, context) { 21 | return hooks.reduce((promise, fn) => promise.then(fn.bind(context)), resolve()); 22 | } 23 | 24 | function setupPauseTest(context) { 25 | let originalPauseTest = context.pauseTest; 26 | context.pauseTest = function Mocha_pauseTest() { 27 | context.timeout(0); // prevent the test from timing out 28 | 29 | return originalPauseTest.call(context); 30 | }; 31 | } 32 | 33 | export default function setupTest(options) { 34 | let originalContext; 35 | let beforeEachHooks = []; 36 | let afterEachHooks = []; 37 | 38 | beforeEach(function() { 39 | originalContext = _assign({}, this); 40 | 41 | return setupContext(this, options) 42 | .then(() => setupPauseTest(this)) 43 | .then(() => chainHooks(beforeEachHooks, this)); 44 | }); 45 | 46 | afterEach(function() { 47 | return chainHooks(afterEachHooks, this) 48 | .then(() => teardownContext(this)) 49 | .then(() => { 50 | // delete any extraneous properties 51 | for (let key in this) { 52 | if (!(key in originalContext)) { 53 | // starting from Ember 3.13 this seems to be necessary 54 | if (teardownMandatorySetter) { 55 | teardownMandatorySetter(this, key); 56 | } 57 | 58 | delete this[key]; 59 | } 60 | } 61 | 62 | // copy over the original values 63 | _assign(this, originalContext); 64 | }); 65 | }); 66 | 67 | /** 68 | * Provide a workaround for the inconvenient FIFO-always order of beforeEach/afterEach calls 69 | * 70 | * ```js 71 | * let hooks = setupTest(); 72 | * hooks.beforeEach(function() { ... }); 73 | * hooks.afterEach(function() { ... }); 74 | * ``` 75 | * 76 | * beforeEach hooks are called after setupUnitTest#beforeEach in FIFO (first in first out) order 77 | * afterEach hooks are called before setupUnitTest#afterEach in LIFO (last in first out) order 78 | * 79 | * @type {{beforeEach: (function(*)), afterEach: (function(*))}} 80 | */ 81 | let hooks = { 82 | beforeEach(fn) { 83 | beforeEachHooks.push(fn); 84 | }, 85 | afterEach(fn) { 86 | afterEachHooks.unshift(fn); 87 | } 88 | }; 89 | 90 | return hooks; 91 | } 92 | -------------------------------------------------------------------------------- /addon-test-support/ember-mocha/test-loader.js: -------------------------------------------------------------------------------- 1 | import { describe, it } from 'mocha'; 2 | import AbstractTestLoader, { 3 | addModuleIncludeMatcher, 4 | } from 'ember-cli-test-loader/test-support/index'; 5 | 6 | addModuleIncludeMatcher(function(moduleName) { 7 | return moduleName.match(/\.jshint$/); 8 | }); 9 | 10 | export class TestLoader extends AbstractTestLoader { 11 | shouldLoadModule(moduleName) { 12 | return !moduleName.match(/^ember-mocha\//) 13 | && (moduleName.match(/[-_]test$/) || moduleName.match(/\.jshint$/)); 14 | } 15 | 16 | moduleLoadFailure(moduleName, error) { 17 | describe('TestLoader Failures', function() { 18 | it(moduleName + ': could not be loaded', function() { 19 | throw error; 20 | }); 21 | }); 22 | } 23 | } 24 | 25 | /** 26 | * Load tests following the default patterns: 27 | * 28 | * - The module name ends with `-test` or `_test` 29 | * - The module name ends with `.jshint` 30 | */ 31 | export function loadTests() { 32 | new TestLoader().loadModules(); 33 | } 34 | -------------------------------------------------------------------------------- /addon-test-support/mocha/index.js: -------------------------------------------------------------------------------- 1 | import Ember from 'ember'; 2 | 3 | /** 4 | * Takes a function that defines a mocha hook, like `beforeEach` and 5 | * runs its callback inside an `Ember.run`. 6 | * 7 | * In the canonical mocha style, beforeEach/afterEach blocks are for 8 | * taking actions that have potentially asynchronous side effects like 9 | * making network requests, and in the case of ember doing things like 10 | * sending events, or visiting pages. In the context of an Ember 11 | * application this more often than not means doing something inside 12 | * of an `Ember.run`. The resulting wrapper has a reference to 13 | * original hook function as the `withoutEmberRun`. E.g. 14 | * 15 | * import { beforeEach } from 'mocha'; 16 | * 17 | * beforeEach(function { 18 | * // this is run inside `Ember.run` 19 | * }) 20 | 21 | * beforeEach.withoutEmberRun(function({ 22 | * // this is not inside `Ember.run` 23 | * })) 24 | * 25 | * You should almost never need to use the version without `Ember.run` 26 | * 27 | * Mocha supports two invocation styles for its hooks depending on the 28 | * synchronization requirements of the setup code, and this wrapper 29 | * supports both of them. 30 | * 31 | * As normal, if the setup code returns a promise, the testcase will 32 | * wait until the promise is settled. 33 | 34 | * @param {Function} original The native mocha hook to wrap 35 | * @returns {Function} the wrapped hook 36 | * @private 37 | */ 38 | function wrapMochaHookInEmberRun(original) { 39 | function wrapper(fn) { 40 | // the callback expects a `done` parameter 41 | if (fn.length) { 42 | return original(function(done) { 43 | return Ember.run((function(_this) { 44 | return function() { 45 | return fn.call(_this, done); 46 | }; 47 | })(this)); 48 | }); 49 | } else { 50 | // no done parameter. 51 | return original(function() { 52 | return Ember.run((function(_this) { 53 | return function() { 54 | return fn.call(_this); 55 | }; 56 | })(this)); 57 | }); 58 | } 59 | } 60 | wrapper.withoutEmberRun = original; 61 | return wrapper; 62 | } 63 | 64 | var mocha = window.mocha; 65 | var describe = window.describe; 66 | var context = window.context; 67 | var it = window.it; 68 | var before = window.before; 69 | var beforeEach = wrapMochaHookInEmberRun(window.beforeEach); 70 | var after = window.after; 71 | var afterEach = wrapMochaHookInEmberRun(window.afterEach); 72 | 73 | export { 74 | mocha, 75 | describe, 76 | context, 77 | it, 78 | before, 79 | beforeEach, 80 | after, 81 | afterEach 82 | }; 83 | -------------------------------------------------------------------------------- /blueprints/ember-mocha/files/tests/test-helper.js: -------------------------------------------------------------------------------- 1 | import Application from '../app'; 2 | import config from '../config/environment'; 3 | import { setApplication } from '@ember/test-helpers'; 4 | import { start } from 'ember-mocha'; 5 | 6 | setApplication(Application.create(config.APP)); 7 | 8 | start(); 9 | -------------------------------------------------------------------------------- /blueprints/ember-mocha/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'ember-mocha', 3 | 4 | normalizeEntityName() { 5 | // this prevents an error when the entityName is 6 | // not specified (since that doesn't actually matter 7 | // to us 8 | }, 9 | 10 | afterInstall() { 11 | return Promise.resolve() 12 | .then(() => this.removeQUnit()) 13 | .then(() => this.addChai()); 14 | }, 15 | 16 | removeQUnit() { 17 | var packages = ['ember-cli-qunit', 'ember-qunit', 'qunit-dom']; 18 | return this.removePackagesFromProject(packages.map(name => ({ name }))); 19 | }, 20 | 21 | addChai() { 22 | return this.addPackagesToProject([ 23 | { name: 'ember-cli-chai', target: '^0.5.0' }, 24 | { name: 'chai-dom', target: '^1.0.0' }, 25 | ]); 26 | }, 27 | }; 28 | -------------------------------------------------------------------------------- /config/ember-try.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const getChannelURL = require('ember-source-channel-url'); 4 | 5 | module.exports = function() { 6 | return Promise.all([ 7 | getChannelURL('release'), 8 | getChannelURL('beta'), 9 | getChannelURL('canary') 10 | ]).then((urls) => { 11 | return { 12 | useYarn: true, 13 | scenarios: [ 14 | { 15 | name: 'ember-lts-3.4', 16 | npm: { 17 | devDependencies: { 18 | 'ember-source': '~3.4.0' 19 | } 20 | } 21 | }, 22 | { 23 | name: 'ember-lts-3.8', 24 | npm: { 25 | devDependencies: { 26 | 'ember-source': '~3.8.0' 27 | } 28 | } 29 | }, 30 | { 31 | name: 'ember-release', 32 | npm: { 33 | devDependencies: { 34 | 'ember-source': urls[0] 35 | } 36 | } 37 | }, 38 | { 39 | name: 'ember-beta', 40 | npm: { 41 | devDependencies: { 42 | 'ember-source': urls[1] 43 | } 44 | } 45 | }, 46 | { 47 | name: 'ember-canary', 48 | npm: { 49 | devDependencies: { 50 | 'ember-source': urls[2] 51 | } 52 | } 53 | }, 54 | // The default `.travis.yml` runs this scenario via `npm test`, 55 | // not via `ember try`. It's still included here so that running 56 | // `ember try:each` manually or from a customized CI config will run it 57 | // along with all the other scenarios. 58 | { 59 | name: 'ember-default', 60 | npm: { 61 | devDependencies: {} 62 | } 63 | }, 64 | ] 65 | }; 66 | }); 67 | }; 68 | -------------------------------------------------------------------------------- /config/environment.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | module.exports = function(/* environment, appConfig */) { 5 | return { }; 6 | }; 7 | -------------------------------------------------------------------------------- /docs/legacy.md: -------------------------------------------------------------------------------- 1 | 2 | Legacy Guide 3 | ============================================================================== 4 | 5 | This document describes the use of Ember Mocha with Ember's legacy testing 6 | APIs, which have been superseded by the newer testing system based on the RFCs 7 | [232](https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md) 8 | and 9 | [268](https://github.com/emberjs/rfcs/blob/master/text/0268-acceptance-testing-refactor.md). 10 | 11 | Usage 12 | ------------------------------------------------------------------------------ 13 | 14 | ### Setting the Resolver 15 | 16 | You'll typically want to set a single resolver for your test suite: 17 | 18 | ```javascript 19 | import resolver from './helpers/resolver'; 20 | import { setResolver } from 'ember-mocha'; 21 | 22 | setResolver(resolver); 23 | ``` 24 | 25 | If you want to use multiple resolvers in your test suite, you can also 26 | call `setResolver` in the `beforeSetup` callback of your test modules. 27 | 28 | ### Setup Tests 29 | 30 | The `setupTest` function can be used to setup a unit test for any kind 31 | of "module/unit" of your application that can be looked up in a container. 32 | 33 | For example, the following is a unit test for the `SidebarController`: 34 | 35 | ```javascript 36 | import { describe, it } from 'mocha'; 37 | import { setupTest } from 'ember-mocha'; 38 | 39 | describe('SidebarController', function() { 40 | setupTest('controller:sidebar', { 41 | // Specify the other units that are required for this test. 42 | // needs: ['controller:foo'] 43 | }); 44 | 45 | // Replace this with your real tests. 46 | it('exists', function() { 47 | var controller = this.subject(); 48 | expect(controller).to.be.ok; 49 | }); 50 | }); 51 | 52 | ``` 53 | 54 | The subject is specified as `controller:sidebar`, which is the key that will 55 | be used to look up this controller in the isolated container that will be 56 | created for this test. 57 | 58 | #### Setup Component Tests 59 | 60 | The `setupComponentTest` function is specifically designed to test components 61 | and provides additional `render` and `$` helpers within a test's context. 62 | 63 | ```javascript 64 | import { describe, it } from 'mocha'; 65 | import { setupComponentTest } from 'ember-mocha'; 66 | 67 | describe('GravatarImageComponent', function() { 68 | setupComponentTest('gravatar-image', { 69 | // specify the other units that are required for this test 70 | // needs: ['component:foo', 'helper:bar'] 71 | }); 72 | 73 | it('renders', function() { 74 | // creates the component instance 75 | var component = this.subject(); 76 | expect(component._state).to.equal('preRender'); 77 | 78 | // renders the component on the page 79 | this.render(); 80 | expect(component._state).to.equal('inDOM'); 81 | }); 82 | }); 83 | ``` 84 | 85 | #### Setup Model Tests 86 | 87 | The `setupModelTest` function can be used to test Ember Data models and 88 | provides an additional `store` helper within a test's context. 89 | 90 | ```javascript 91 | import { describe, it } from 'mocha'; 92 | import { setupModelTest } from 'ember-mocha'; 93 | 94 | describe('Contact', function() { 95 | setupModelTest('contact', { 96 | // Specify the other units that are required for this test. 97 | needs: [] 98 | }); 99 | 100 | // Replace this with your real tests. 101 | it('exists', function() { 102 | var model = this.subject(); 103 | // var store = this.store(); 104 | expect(model).to.be.ok; 105 | }); 106 | }); 107 | ``` 108 | 109 | 110 | ### Acceptance Tests 111 | 112 | The `setupAcceptanceTest` function can be used to run acceptance 113 | tests as the name suggests. It will automatically setup an 114 | application instance for you, which is provided at `this.application`. 115 | 116 | ```javascript 117 | import Ember from 'ember'; 118 | import { describe, it } from 'mocha'; 119 | import { setupAcceptanceTest } from 'ember-mocha'; 120 | 121 | var Application = Ember.Application.extend({ 122 | rootElement: '#ember-testing', 123 | }); 124 | 125 | describe('basic acceptance test', function() { 126 | setupAcceptanceTest({ Application }); 127 | 128 | it('can visit /', function() { 129 | visit('/'); 130 | 131 | andThen(() => { 132 | expect(currentURL()).to.equal('/'); 133 | }); 134 | }); 135 | }); 136 | ``` 137 | 138 | #### Using `async/await` 139 | 140 | In case your project supports the `async/await` feature of ES2016 you can 141 | simplify the test function to this: 142 | 143 | ```js 144 | it('can visit /', async function() { 145 | await visit('/'); 146 | expect(currentURL()).to.equal('/'); 147 | }); 148 | ``` 149 | 150 | - add the `async` keyword in front of the test `function` 151 | - add `await` in front of all async test helper calls 152 | - remove the `andThen()` wrappers 153 | -------------------------------------------------------------------------------- /docs/migration.md: -------------------------------------------------------------------------------- 1 | 2 | Migration Guide 3 | ============================================================================== 4 | 5 | This guide provides instruction for upgrading your test suite 6 | * from the [Legacy APIs](legacy.md) to Ember's latest testing APIs based 7 | on RFCs 8 | [232](https://github.com/emberjs/rfcs/blob/master/text/0232-simplify-qunit-testing-api.md) 9 | and 10 | [268](https://github.com/emberjs/rfcs/blob/master/text/0268-acceptance-testing-refactor.md). 11 | * from very early releases of Ember Mocha, based on custom `describe*` 12 | functions to the later introduced `setupTest()` functions, both based on 13 | Ember's [Legacy APIs](legacy.md) 14 | 15 | Upgrading to the new testing APIs 16 | ------------------------------------------------------------------------------ 17 | 18 | For the complete introduction to the new testing APIs, please read the 19 | latest [Ember Guides](https://guides.emberjs.com/v3.0.0/testing/). The 20 | following examples will give you an overview how to migrate your existing Ember 21 | Mocha based test suite. 22 | 23 | ### Unit tests 24 | 25 | Before: 26 | 27 | ```javascript 28 | import { expect } from 'chai'; 29 | import { describe, it } from 'mocha'; 30 | import { setupTest } from 'ember-mocha'; 31 | 32 | describe('SidebarController', function() { 33 | setupTest('controller:sidebar', { 34 | // Specify the other units that are required for this test. 35 | // needs: ['controller:foo'] 36 | }); 37 | 38 | // Replace this with your real tests. 39 | it('exists', function() { 40 | var controller = this.subject(); 41 | expect(controller).to.be.ok; 42 | }); 43 | }); 44 | ``` 45 | 46 | After: 47 | 48 | ```javascript 49 | import { expect } from 'chai'; 50 | import { describe, it } from 'mocha'; 51 | import { setupTest } from 'ember-mocha'; 52 | 53 | describe('SidebarController', function() { 54 | setupTest(); 55 | 56 | // Replace this with your real tests. 57 | it('exists', function() { 58 | let controller = this.owner.lookup('controller:sidebar'); 59 | expect(controller).to.be.ok; 60 | }); 61 | }); 62 | ``` 63 | 64 | #### Migration steps 65 | 66 | * Use `setupTest()` without any arguments to opt into the new testing system 67 | * Use the Owner object given by `this.owner` directly instead of `this.subject()` 68 | 69 | ### Component tests 70 | 71 | Before: 72 | 73 | ```javascript 74 | import { expect } from 'chai'; 75 | import { describe, it } from 'mocha'; 76 | import { setupComponentTest } from 'ember-mocha'; 77 | import hbs from 'htmlbars-inline-precompile'; 78 | 79 | describe('GravatarImageComponent', function() { 80 | setupComponentTest('gravatar-image', { 81 | integration: true 82 | }); 83 | 84 | it('renders', function() { 85 | this.render(hbs`{{gravatar-image}}`); 86 | expect(this.$('img')).to.exist; 87 | }); 88 | }); 89 | ``` 90 | 91 | After: 92 | 93 | ```javascript 94 | import { expect } from 'chai'; 95 | import { describe, it } from 'mocha'; 96 | import { setupRenderingTest } from 'ember-mocha'; 97 | import { render } from '@ember/test-helpers'; 98 | import hbs from 'htmlbars-inline-precompile'; 99 | 100 | describe('GravatarImageComponent', function() { 101 | setupRenderingTest(); 102 | 103 | it('renders', async function() { 104 | await render(hbs`{{gravatar-image}}`); 105 | expect(this.element.querySelector('img')).to.exist; 106 | }); 107 | }); 108 | ``` 109 | 110 | #### Migration steps 111 | 112 | * Use `setupRenderingTest()` instead of `setupComponentTest()` 113 | * Render using the `render()` helper from `@ember/test-helpers` instead of 114 | `this.render()` 115 | * `render()` is now always an async call, so use `async`/`await` to wait for it 116 | to complete 117 | * Use `this.element` to get access to the rendered DOM 118 | * Replace `this.on` when testing action invocation with `this.set` and convert `string` references to the action name with the name of the variable that contains the function 119 | * Do not use jQuery for DOM interaction, instead use the 120 | [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers) 121 | from `@ember/test-helpers` 122 | 123 | For migrating to the DOM interaction helpers, you can use the 124 | [ember-test-helpers-codemod](https://github.com/simonihmig/ember-test-helpers-codemod) 125 | to automatically convert all or most of it. 126 | 127 | ### Acceptance tests 128 | 129 | Before: 130 | 131 | ```javascript 132 | import { describe, it, beforeEach, afterEach } from 'mocha'; 133 | import { expect } from 'chai'; 134 | import startApp from 'app/tests/helpers/start-app'; 135 | import destroyApp from 'app/tests/helpers/destroy-app'; 136 | 137 | describe('basic acceptance test', function() { 138 | let application; 139 | 140 | beforeEach(function() { 141 | application = startApp(); 142 | }); 143 | 144 | afterEach(function() { 145 | destroyApp(application); 146 | }); 147 | 148 | it('can visit /', function() { 149 | visit('/'); 150 | 151 | return andThen(() => { 152 | expect(currentURL()).to.equal('/'); 153 | }); 154 | }); 155 | }); 156 | ``` 157 | 158 | After: 159 | 160 | 161 | ```javascript 162 | import { expect } from 'chai'; 163 | import { describe, it } from 'mocha'; 164 | import { setupApplicationTest } from 'ember-mocha'; 165 | import { visit, currentURL } from '@ember/test-helpers'; 166 | 167 | describe('basic acceptance test', function() { 168 | setupApplicationTest(); 169 | 170 | it('can visit /', async function() { 171 | await visit('/'); 172 | expect(currentURL()).to.equal('/'); 173 | }); 174 | }); 175 | ``` 176 | 177 | #### Migration steps 178 | 179 | * Use `setupApplicationTest()` instead of `setupAcceptanceTest()` or the 180 | `beforeEach`/`afterEach` hooks from the example above 181 | * Use the [Routing Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#routing-helpers) 182 | from `@ember/test-helpers` instead of the global helpers, e.g. `visit` 183 | * Do not use the "global" test helpers for DOM interaction, instead use the 184 | [DOM Interaction Helpers](https://github.com/emberjs/ember-test-helpers/blob/master/API.md#dom-interaction-helpers) 185 | from `@ember/test-helpers` 186 | * use `async`/`await` to wait for asynchronous operations like `visit()` or 187 | `click()` 188 | * use `this.element` to get access to the rendered DOM 189 | 190 | For migrating from the global test helpers to those proved by 191 | `@ember/test-helpers`, you can use the 192 | [ember-test-helpers-codemod](https://github.com/simonihmig/ember-test-helpers-codemod) 193 | to assist you with that task. 194 | 195 | 196 | Upgrading from early releases to the legacy testing API 197 | ------------------------------------------------------------------------------ 198 | 199 | Very early releases promoted the use of `describeModule()`, 200 | `describeComponent()` and `describeModel()` instead of the `describe()` 201 | function of Mocha itself. These functions have been deprecated and replaced 202 | by the `setupTest()` functions mentioned in the [Legacy Guide](legacy.md). The 203 | following example will explain how to update your code. 204 | 205 | Before: 206 | 207 | ```js 208 | import { expect } from 'chai'; 209 | import { it } from 'mocha'; 210 | import { describeModule } from 'ember-mocha'; 211 | 212 | describeModule( 213 | 'route:subscribers', 214 | 'Unit: Route: subscribers', 215 | { 216 | needs: ['service:notifications'] 217 | }, 218 | function() { 219 | it('exists', function() { 220 | let route = this.subject(); 221 | expect(route).to.be.ok; 222 | }); 223 | } 224 | ); 225 | ``` 226 | 227 | After: 228 | 229 | ```js 230 | import { expect } from 'chai'; 231 | import { it, describe } from 'mocha'; 232 | import { setupTest } from 'ember-mocha'; 233 | 234 | describe('Unit: Route: subscribers', function() { 235 | setupTest('route:subscribers', { 236 | needs: ['service:notifications'] 237 | }); 238 | 239 | it('exists', function() { 240 | let route = this.subject(); 241 | expect(route).to.be.ok; 242 | }); 243 | }); 244 | ``` 245 | 246 | - import `it()` from `mocha` instead of `ember-mocha` 247 | - replace the `describeModule()` import with a `setupTest()` import 248 | - add a `setupTest()` call to the test `function` with the second and third 249 | argument of the `describeModule()` call (module name and options) 250 | - replace the `describeModule()` call with a `describe()` call with the first 251 | and fourth argument of the `describeModule()` call (description and test 252 | function) 253 | 254 | Instead of refactoring all your files by hand we recommend to use the 255 | [ember-mocha-codemods](https://github.com/Turbo87/ember-mocha-codemods) 256 | to automatically convert your tests: 257 | 258 | ``` 259 | npm install -g jscodeshift 260 | jscodeshift -t https://raw.githubusercontent.com/Turbo87/ember-mocha-codemods/master/import-it-from-mocha.js tests 261 | jscodeshift -t https://raw.githubusercontent.com/Turbo87/ember-mocha-codemods/master/new-testing-api.js tests 262 | ``` 263 | 264 | This will migrate you to the testing API described in the [Legacy Guide](legacy.md). 265 | After that you can follow the other migration guides above to upgrade to the 266 | new shared testing APIs. 267 | -------------------------------------------------------------------------------- /ember-cli-build.js: -------------------------------------------------------------------------------- 1 | /* eslint-env node */ 2 | 'use strict'; 3 | 4 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); 5 | 6 | module.exports = function(defaults) { 7 | let app = new EmberAddon(defaults, { 8 | eslint: { 9 | testGenerator: 'mocha', 10 | }, 11 | }); 12 | 13 | /* 14 | This build file specifies the options for the dummy test app of this 15 | addon, located in `/tests/dummy` 16 | This build file does *not* influence how the addon or the app using it 17 | behave. You most likely want to be modifying `./index.js` or app's build file 18 | */ 19 | 20 | return app.toTree(); 21 | }; 22 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-console, no-process-exit */ 2 | 3 | 'use strict'; 4 | 5 | const path = require('path'); 6 | const stripIndent = require('common-tags').stripIndent; 7 | 8 | module.exports = { 9 | name: 'ember-mocha', 10 | 11 | init() { 12 | this._super.init && this._super.init.apply(this, arguments); 13 | 14 | this.overrideTestCommandFilter(); 15 | this.setTestGenerator(); 16 | }, 17 | 18 | postBuild() { 19 | this.checkPackages(); 20 | }, 21 | 22 | checkPackages() { 23 | var packages = Object.keys(this.project.addonPackages); 24 | if (packages.indexOf('ember-cli-qunit') !== -1) { 25 | console.warn('\nIt looks like you are using "ember-cli-qunit" which can cause issues with "ember-cli-mocha", please remove this package.\n'); 26 | process.exit(1); 27 | } 28 | }, 29 | 30 | included() { 31 | this._super.included.apply(this, arguments); 32 | 33 | this.import('vendor/mocha/mocha.js', { type: 'test' }); 34 | this.import('vendor/mocha/mocha.css', { type: 'test' }); 35 | this.import('vendor/ember-mocha/mocha-configuration.js', { type: 'test' }); 36 | 37 | let addonOptions = this.targetOptions(); 38 | let explicitlyDisabledStyles = addonOptions.disableContainerStyles === true; 39 | if (!explicitlyDisabledStyles) { 40 | this.import('vendor/ember-mocha/test-container-styles.css', { type: 'test' }); 41 | } 42 | }, 43 | 44 | targetOptions() { 45 | if (!this._targetOptions) { 46 | // 1. check this.parent.options['ember-mocha'] 47 | let targetOptions = this.parent.options && this.parent.options['ember-mocha']; 48 | // 2. check this.app.options['ember-mocha'] 49 | targetOptions = targetOptions || (this.app && this.app.options && this.app.options['ember-mocha']); 50 | // 3. check this.parent.options['ember-cli-mocha'] 51 | targetOptions = targetOptions || (this.parent.options && this.parent.options['ember-cli-mocha']); 52 | // 4. check this.app.options['ember-cli-mocha'] 53 | targetOptions = targetOptions || (this.app && this.app.options && this.app.options['ember-cli-mocha']); 54 | this._targetOptions = targetOptions || {}; 55 | } 56 | 57 | return this._targetOptions; 58 | }, 59 | 60 | contentFor(type) { 61 | // Skip if insertContentForTestBody === false. 62 | if (type === 'test-body' && !(this.targetOptions().insertContentForTestBody === false)) { 63 | return stripIndent` 64 |
65 | 66 |