Skip to content

Commit 9c7b3e8

Browse files
Merge pull request #1313 from NullVoxPopuli/vite-support-via-path-argument
Use ember-exam with vite
2 parents 453a3e4 + 17a697d commit 9c7b3e8

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The [documentation website](https://ember-cli.github.io/ember-exam/) contains ex
3939
Installation is as easy as running:
4040

4141
```bash
42-
$ ember install ember-exam
42+
$ npm install --save-dev ember-exam
4343
```
4444

4545
## How To Use
@@ -72,12 +72,49 @@ To get the unique features of Ember Exam (described in-depth below), you will ne
7272

7373
```js
7474
// test-helper.js
75-
import start from 'ember-exam/test-support/start';
75+
import { start } from 'ember-exam/test-support';
7676

7777
// Options passed to `start` will be passed-through to ember-qunit
7878
start();
7979
```
8080

81+
## How to use with Vite
82+
83+
All of the above applies, but we need to tell vite to build the app before telling ember/exam to run tests on that output.
84+
85+
Update your test-helper.js or test-helper.ts, to have add the ember-exam `start` function:
86+
```diff
87+
// ...
88+
import { setApplication } from '@ember/test-helpers';
89+
import { setup } from 'qunit-dom';
90+
- import { start as qunitStart, setupEmberOnerrorValidation } from 'ember-qunit';
91+
+ import { setupEmberOnerrorValidation } from 'ember-qunit';
92+
+ import { start as startEmberExam } from 'ember-exam/test-support';
93+
94+
export function start() {
95+
setApplication(Application.create(config.APP));
96+
97+
setup(QUnit.assert);
98+
setupEmberOnerrorValidation();
99+
100+
- qunitStart();
101+
+ // Options passed to `start` will be passed-through to ember-qunit
102+
+ startEmberExam();
103+
}
104+
```
105+
106+
Testing development:
107+
```bash
108+
NODE_ENV=development vite build --mode test
109+
ember exam --path dist
110+
```
111+
112+
Testing production:
113+
```bash
114+
vite build --mode test
115+
ember exam --path dist
116+
```
117+
81118
### Version < `3.0.0`
82119

83120

addon-test-support/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as start } from './start';

0 commit comments

Comments
 (0)