@bagaar/ember-graphql-mocking 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+
3
+ ## v0.4.0 (2022-02-03)
4
+
5
+ #### :rocket: Enhancement
6
+ * [#18](https://github.com/Bagaar/ember-graphql-mocking/pull/18) Make `msw` start options configurable ([@bertdeblock](https://github.com/bertdeblock))
7
+
8
+ #### Committers: 1
9
+ - Bert De Block ([@bertdeblock](https://github.com/bertdeblock))
10
+
2
11
  ## v0.3.2 (2022-02-02)
3
12
 
4
13
  #### :house: Internal
@@ -1,12 +1,19 @@
1
1
  import { assert } from '@ember/debug';
2
2
  import { buildASTSchema, graphql } from 'graphql';
3
+ import merge from 'lodash.merge';
3
4
  import { graphql as mswGraphql, setupWorker } from 'msw';
4
5
  import { done as qunitDone } from 'qunit';
5
6
 
6
7
  const IS_TESTEM = Boolean(window.Testem);
7
8
  const DEFAULT_OPTIONS = {
8
- quiet: IS_TESTEM,
9
- scope: IS_TESTEM ? window.location.pathname : '/tests',
9
+ mswStartOptions: {
10
+ quiet: IS_TESTEM,
11
+ serviceWorker: {
12
+ options: {
13
+ scope: IS_TESTEM ? window.location.pathname : '/tests',
14
+ },
15
+ },
16
+ },
10
17
  };
11
18
 
12
19
  let isSetupGraphqlTestCalled = false;
@@ -14,10 +21,7 @@ let root = null;
14
21
  let worker = null;
15
22
 
16
23
  export function setupEmberGraphqlMocking(schemaDocument, providedOptions) {
17
- const options = {
18
- ...DEFAULT_OPTIONS,
19
- ...providedOptions,
20
- };
24
+ const options = merge({}, DEFAULT_OPTIONS, providedOptions);
21
25
 
22
26
  createWorker(options);
23
27
  createGraphqlOperationHandler(schemaDocument);
@@ -46,18 +50,12 @@ export function getWorker() {
46
50
  function createWorker(options) {
47
51
  worker = setupWorker();
48
52
 
49
- worker.start({
50
- quiet: options.quiet,
51
- serviceWorker: {
52
- options: {
53
- scope: options.scope,
54
- },
55
- },
56
- });
53
+ worker.start(options.mswStartOptions);
57
54
  }
58
55
 
59
56
  function destroyWorker() {
60
57
  worker.stop();
58
+
61
59
  worker = null;
62
60
  }
63
61
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bagaar/ember-graphql-mocking",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Ember addon for mocking GraphQL requests using Mock Service Worker (MSW).",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -37,6 +37,7 @@
37
37
  "ember-auto-import": "^2.2.4",
38
38
  "ember-cli-babel": "^7.26.11",
39
39
  "graphql": "^16.3.0",
40
+ "lodash.merge": "^4.6.2",
40
41
  "msw": "0.36.7",
41
42
  "qunit": "^2.17.2"
42
43
  },