@ornikar/jest-config-react 7.2.0-alpha.1 → 7.3.1-beta.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,29 @@
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
+ # [7.3.0](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react@7.2.0...@ornikar/jest-config-react@7.3.0) (2021-11-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * add waitFor in stories mock [no issue] ([#550](https://github.com/ornikar/shared-configs/issues/550)) ([9a4f254](https://github.com/ornikar/shared-configs/commit/9a4f25431cf556099b6c48dd52670937526c19b7))
12
+
13
+
14
+
15
+
16
+
17
+ # [7.2.0](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react@7.1.1...@ornikar/jest-config-react@7.2.0) (2021-11-29)
18
+
19
+
20
+ ### Features
21
+
22
+ * **deps:** update dependency @testing-library/react to v12 ([#547](https://github.com/ornikar/shared-configs/issues/547)) ([31eefb7](https://github.com/ornikar/shared-configs/commit/31eefb74293eb36f304d65a396abd10a61589f29))
23
+ * **deps:** update dependency @testing-library/react-hooks to v7.0.2 ([#548](https://github.com/ornikar/shared-configs/issues/548)) ([2dfb8c7](https://github.com/ornikar/shared-configs/commit/2dfb8c79b31ad4211cd2a41fc31c432b39b1de3b))
24
+
25
+
26
+
27
+
28
+
6
29
  ## [7.1.1](https://github.com/ornikar/shared-configs/compare/@ornikar/jest-config-react@7.1.0...@ornikar/jest-config-react@7.1.1) (2021-11-18)
7
30
 
8
31
  **Note:** Version bump only for package @ornikar/jest-config-react
@@ -2,7 +2,7 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- const { act, render } = require('@testing-library/react');
5
+ const { act, render, waitFor } = require('@testing-library/react');
6
6
 
7
7
  const wait = (amount = 0) => new Promise((resolve) => setTimeout(resolve, amount));
8
8
 
@@ -49,7 +49,7 @@ exports.storiesOf = (groupName) => {
49
49
  const parameters = { ...localParameters, ...storyParameters };
50
50
  const context = { name: storyName, parameters };
51
51
  const { jest } = parameters;
52
- const { ignore, ignoreDecorators } = jest || {};
52
+ const { ignore, ignoreDecorators, createBeforeAfterEachCallbacks, waitFor: waitForExpectation } = jest || {};
53
53
 
54
54
  if (ignore) {
55
55
  test.skip(storyName, () => {});
@@ -57,17 +57,24 @@ exports.storiesOf = (groupName) => {
57
57
  }
58
58
 
59
59
  describe(groupName, () => {
60
+ if (createBeforeAfterEachCallbacks) {
61
+ const { before, after } = createBeforeAfterEachCallbacks();
62
+ if (before) beforeEach(before);
63
+ if (after) afterEach(after);
64
+ }
65
+
60
66
  it(storyName, async () => {
61
67
  const wrappingComponent = ignoreDecorators
62
68
  ? undefined
63
69
  : ({ children }) => decorateStory(() => children, [...localDecorators, ...globalDecorators])(context);
64
70
 
65
71
  await act(async () => {
66
- const { unmount, asFragment } = render(story(context), { wrapper: wrappingComponent });
72
+ const rtlApi = render(story(context), { wrapper: wrappingComponent });
73
+ const { unmount, asFragment } = rtlApi;
67
74
  // https://www.apollographql.com/docs/react/development-testing/testing/#testing-final-state
68
75
  // delays until the next "tick" of the event loop, and allows time
69
76
  // for that Promise returned from MockedProvider to be fulfilled
70
- await wait(0);
77
+ await (waitForExpectation ? waitFor(() => waitForExpectation(rtlApi, expect)) : wait(0));
71
78
  expect(asFragment()).toMatchSnapshot();
72
79
  unmount();
73
80
  });
package/jest-preset.js CHANGED
@@ -19,7 +19,6 @@ module.exports = {
19
19
  '\\.svg$': require.resolve('./fileTransform'),
20
20
  }
21
21
  : {
22
- '\\.inline\\.svg$': 'jest-svg-transformer',
23
22
  '\\.svg$': require.resolve('./fileTransform'),
24
23
  '^.+\\.(js|jsx|ts|tsx)$': '<rootDir>/node_modules/babel-jest',
25
24
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornikar/jest-config-react",
3
- "version": "7.2.0-alpha.1",
3
+ "version": "7.3.1-beta.1",
4
4
  "description": "jest config",
5
5
  "repository": "ornikar/shared-configs",
6
6
  "main": "jest-preset.js",
@@ -12,8 +12,8 @@
12
12
  "access": "public"
13
13
  },
14
14
  "peerDependencies": {
15
- "@testing-library/react": "^11.2.5",
16
- "@testing-library/react-hooks": "^5.1.0",
15
+ "@testing-library/react": "^11.2.5 || ^12.0.0",
16
+ "@testing-library/react-hooks": "^5.1.0 || ^7.0.0",
17
17
  "react": "^16.6.3 || ^17.0.0",
18
18
  "react-dom": "^16.6.3 || ^17.0.0"
19
19
  },
@@ -22,9 +22,8 @@
22
22
  "identity-obj-proxy": "^3.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@testing-library/react": "11.2.7",
26
- "@testing-library/react-hooks": "5.1.3",
27
- "jest-svg-transformer": "^1.0.0",
25
+ "@testing-library/react": "12.1.2",
26
+ "@testing-library/react-hooks": "7.0.2",
28
27
  "react": "17.0.2"
29
28
  }
30
29
  }