Skip to content

Commit

Permalink
Merge pull request #24 from Bagaar/dont-auto-stop-the-worker-when-tes…
Browse files Browse the repository at this point in the history
…ts-are-done

Don't automatically stop the worker when all tests are done (fix compat with `ember-cli-code-coverage@v1`)
  • Loading branch information
bertdeblock authored Feb 9, 2022
2 parents 871ba8f + b8280cd commit deab236
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions addon-test-support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { assert } from '@ember/debug';
import { buildASTSchema, graphql } from 'graphql';
import merge from 'lodash.merge';
import { graphql as mswGraphql, setupWorker } from 'msw';
import { done as qunitDone } from 'qunit';

const IS_TESTEM = Boolean(window.Testem);
const DEFAULT_OPTIONS = {
Expand All @@ -25,7 +24,6 @@ export function setupEmberGraphqlMocking(schemaDocument, providedOptions) {

createWorker(options);
createGraphqlOperationHandler(schemaDocument);
qunitDone(destroyWorker);
}

export function setupGraphqlTest(hooks) {
Expand All @@ -47,16 +45,16 @@ export function getWorker() {
return worker;
}

function createWorker(options) {
worker = setupWorker();
export function destroyWorker() {
worker.stop();

worker.start(options.mswStartOptions);
worker = null;
}

function destroyWorker() {
worker.stop();
function createWorker(options) {
worker = setupWorker();

worker = null;
worker.start(options.mswStartOptions);
}

function createGraphqlOperationHandler(schemaDocument) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@
"ember-cli-babel": "^7.26.11",
"graphql": "^16.3.0",
"lodash.merge": "^4.6.2",
"msw": "0.36.7",
"qunit": "^2.17.2"
"msw": "0.36.7"
},
"devDependencies": {
"@commitlint/cli": "^16.1.0",
Expand Down Expand Up @@ -79,6 +78,7 @@
"loader.js": "^4.7.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.5.1",
"qunit": "^2.17.2",
"qunit-dom": "^2.0.0",
"release-it": "^14.2.1",
"release-it-lerna-changelog": "^4.0.1",
Expand Down

0 comments on commit deab236

Please sign in to comment.