Skip to content

Commit 430b5e7

Browse files
committed
mirage: Start ember-cli-mirage server only if window.startMirage is set
This will allow us to selectively enable Mirage only for some tests in the playwright test suite
1 parent b9806b2 commit 430b5e7

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { importSync, isDevelopingApp, isTesting, macroCondition } from '@embroider/macros';
2+
3+
export default {
4+
name: 'ember-cli-mirage',
5+
initialize(application) {
6+
if (macroCondition(isTesting() || isDevelopingApp())) {
7+
let startMirage = importSync('ember-cli-mirage/start-mirage').default;
8+
let ENV = importSync('../config/environment').default;
9+
let makeServer = importSync('../mirage/config').default;
10+
11+
application.register('mirage:make-server', makeServer, {
12+
instantiate: false,
13+
});
14+
15+
if (window.startMirage) {
16+
startMirage(application.__container__, { makeServer, env: ENV });
17+
}
18+
}
19+
},
20+
};

e2e/fixtures/mirage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export class MiragePage {
4949
}
5050

5151
async setup() {
52+
await this.page.addInitScript('window.startMirage = true');
5253
await this.addHelpers();
5354
}
5455
}

0 commit comments

Comments
 (0)