@ornikar/jest-config-react 8.0.0 → 9.0.1

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
@@ -3,6 +3,41 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [9.0.1](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react@9.0.0...@ornikar/jest-config-react@9.0.1) (2022-01-05)
7
+
8
+ **Note:** Version bump only for package @ornikar/jest-config-react
9
+
10
+
11
+
12
+
13
+
14
+ # [9.0.0](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react@8.0.1...@ornikar/jest-config-react@9.0.0) (2021-12-15)
15
+
16
+
17
+ ### Features
18
+
19
+ * **jest-config-react:** remove random wait, add global addParameters [no issue] ([#601](https://github.com/ornikar/shared-configs/issues/601)) ([764ef11](https://github.com/ornikar/shared-configs/commit/764ef11d9bd29e309438040e06fbdf4f9f6a2e9e))
20
+
21
+
22
+ ### BREAKING CHANGES
23
+
24
+ * **jest-config-react:** wait(0) is removed, if you need to wait add waitFor: () => wait(0)
25
+
26
+
27
+
28
+
29
+
30
+ ## [8.0.1](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react@8.0.0...@ornikar/jest-config-react@8.0.1) (2021-12-09)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * downgrade node minimum required version [no issue] ([#595](https://github.com/ornikar/shared-configs/issues/595)) ([9464687](https://github.com/ornikar/shared-configs/commit/9464687f55aed4a2e683f5d3b992300d000a2b30))
36
+
37
+
38
+
39
+
40
+
6
41
  # [8.0.0](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react@7.3.0...@ornikar/jest-config-react@8.0.0) (2021-12-07)
7
42
 
8
43
 
@@ -4,8 +4,6 @@
4
4
 
5
5
  const { act, render, waitFor } = require('@testing-library/react');
6
6
 
7
- const wait = (amount = 0) => new Promise((resolve) => setTimeout(resolve, amount));
8
-
9
7
  const decorateStory = (storyFn, decorators) =>
10
8
  decorators.reduce(
11
9
  (decorated, decorator) =>
@@ -29,12 +27,18 @@ const decorateStory = (storyFn, decorators) =>
29
27
  );
30
28
 
31
29
  const globalDecorators = [];
30
+ const globalParameters = {};
32
31
 
33
32
  // Mocked version of `import { addDecorator } from '@storybook/react'`.
34
33
  exports.addDecorator = (decorator) => {
35
34
  globalDecorators.push(decorator);
36
35
  };
37
36
 
37
+ // Mocked version of `import { addParameters } from '@storybook/react'`.
38
+ exports.addParameters = (parameters) => {
39
+ Object.assign(globalParameters, parameters);
40
+ };
41
+
38
42
  // Mocked version of `import { action } from '@storybook/react'`.
39
43
  exports.action = (actionName) => jest.fn();
40
44
 
@@ -46,7 +50,7 @@ exports.storiesOf = (groupName) => {
46
50
  // Mocked API to generate tests from & snapshot stories.
47
51
  const api = {
48
52
  add(storyName, story, storyParameters = {}) {
49
- const parameters = { ...localParameters, ...storyParameters };
53
+ const parameters = { ...globalParameters, ...localParameters, ...storyParameters };
50
54
  const context = { name: storyName, parameters };
51
55
  const { jest } = parameters;
52
56
  const { ignore, ignoreDecorators, createBeforeAfterEachCallbacks, waitFor: waitForExpectation } = jest || {};
@@ -71,10 +75,9 @@ exports.storiesOf = (groupName) => {
71
75
  await act(async () => {
72
76
  const rtlApi = render(story(context), { wrapper: wrappingComponent });
73
77
  const { unmount, asFragment } = rtlApi;
74
- // https://www.apollographql.com/docs/react/development-testing/testing/#testing-final-state
75
- // delays until the next "tick" of the event loop, and allows time
76
- // for that Promise returned from MockedProvider to be fulfilled
77
- await (waitForExpectation ? waitFor(() => waitForExpectation(rtlApi, expect)) : wait(0));
78
+ if (waitForExpectation) {
79
+ await waitFor(() => waitForExpectation(rtlApi, expect, { parameters }));
80
+ }
78
81
  expect(asFragment()).toMatchSnapshot();
79
82
  unmount();
80
83
  });
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ornikar/jest-config-react",
3
- "version": "8.0.0",
3
+ "version": "9.0.1",
4
4
  "description": "jest config",
5
5
  "repository": "ornikar/shared-configs",
6
6
  "main": "jest-preset.js",
7
7
  "license": "ISC",
8
8
  "engines": {
9
- "node": ">=14.17.6"
9
+ "node": ">=14.17.5"
10
10
  },
11
11
  "publishConfig": {
12
12
  "access": "public"
@@ -18,7 +18,7 @@
18
18
  "react-dom": "^16.6.3 || ^17.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "@ornikar/jest-config": "^7.0.0",
21
+ "@ornikar/jest-config": "^7.1.0",
22
22
  "identity-obj-proxy": "^3.0.0"
23
23
  },
24
24
  "devDependencies": {
@@ -26,5 +26,5 @@
26
26
  "@testing-library/react-hooks": "7.0.2",
27
27
  "react": "17.0.2"
28
28
  },
29
- "gitHead": "2e424ab4fb1742312586f4c975c937f74109352e"
29
+ "gitHead": "9f298f2b085415d8ba48da3d07db25c1ea73763e"
30
30
  }