Skip to content

Commit e0b1249

Browse files
authored
chore: update babel-plugin-tester (#13804)
1 parent b9282e1 commit e0b1249

File tree

3 files changed

+183
-192
lines changed

3 files changed

+183
-192
lines changed

packages/babel-plugin-jest-hoist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@types/babel__template": "^7.0.2",
3333
"@types/node": "*",
3434
"@types/prettier": "^2.1.5",
35-
"babel-plugin-tester": "^10.0.0",
35+
"babel-plugin-tester": "^11.0.2",
3636
"prettier": "^2.1.1"
3737
},
3838
"publishConfig": {
Lines changed: 87 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`babel-plugin-jest-hoist TS typeof usage in jest.mock: TS typeof usage in jest.mock 1`] = `
4-
5-
jest.mock('some-module', () => {
6-
const actual = jest.requireActual('some-module');
7-
8-
return jest.fn<typeof actual.method>();
9-
});
10-
11-
↓ ↓ ↓ ↓ ↓ ↓
12-
13-
_getJestObj().mock('some-module', () => {
14-
const actual = jest.requireActual('some-module');
15-
return jest.fn();
16-
});
17-
function _getJestObj() {
18-
const {jest} = require('@jest/globals');
19-
_getJestObj = () => jest;
20-
return jest;
21-
}
22-
23-
24-
`;
25-
26-
exports[`babel-plugin-jest-hoist automatic react runtime: automatic react runtime 1`] = `
3+
exports[`babel-plugin-jest-hoist 1. automatic react runtime: 1. automatic react runtime 1`] = `
274
285
jest.mock('./App', () => () => <div>Hello world</div>);
296
7+
308
↓ ↓ ↓ ↓ ↓ ↓
319
3210
var _jsxFileName = '/root/project/src/file.js';
@@ -55,60 +33,98 @@ function _getJestObj() {
5533
return jest;
5634
}
5735
36+
`;
37+
38+
exports[`babel-plugin-jest-hoist 2. top level mocking: 2. top level mocking 1`] = `
39+
40+
require('x');
41+
42+
jest.enableAutomock();
43+
jest.disableAutomock();
44+
45+
46+
↓ ↓ ↓ ↓ ↓ ↓
47+
48+
_getJestObj().enableAutomock();
49+
_getJestObj().disableAutomock();
50+
function _getJestObj() {
51+
const {jest} = require('@jest/globals');
52+
_getJestObj = () => jest;
53+
return jest;
54+
}
55+
require('x');
5856
5957
`;
6058

61-
exports[`babel-plugin-jest-hoist global jest.mock within jest.mock: global jest.mock within jest.mock 1`] = `
59+
exports[`babel-plugin-jest-hoist 3. within a block: 3. within a block 1`] = `
6260
63-
jest.mock('some-module', () => {
64-
jest.mock('some-module');
61+
beforeEach(() => {
62+
require('x');
63+
jest.mock('someNode');
6564
});
6665
66+
6767
↓ ↓ ↓ ↓ ↓ ↓
6868
69-
_getJestObj().mock('some-module', () => {
70-
_getJestObj().mock('some-module');
71-
});
7269
function _getJestObj() {
7370
const {jest} = require('@jest/globals');
7471
_getJestObj = () => jest;
7572
return jest;
7673
}
77-
74+
beforeEach(() => {
75+
_getJestObj().mock('someNode');
76+
require('x');
77+
});
7878
7979
`;
8080

81-
exports[`babel-plugin-jest-hoist global jest.requireActual in jest.mock: global jest.requireActual in jest.mock 1`] = `
81+
exports[`babel-plugin-jest-hoist 4. within a block with no siblings: 4. within a block with no siblings 1`] = `
8282
83-
jest.mock('some-module', () => {
84-
jest.requireActual('some-module');
83+
beforeEach(() => {
84+
jest.mock('someNode');
8585
});
8686
87-
jest.requireActual('some-module');
8887
8988
↓ ↓ ↓ ↓ ↓ ↓
9089
91-
_getJestObj().mock('some-module', () => {
92-
_getJestObj().requireActual('some-module');
93-
});
9490
function _getJestObj() {
9591
const {jest} = require('@jest/globals');
9692
_getJestObj = () => jest;
9793
return jest;
9894
}
99-
jest.requireActual('some-module');
95+
beforeEach(() => {
96+
_getJestObj().mock('someNode');
97+
});
98+
99+
`;
100+
101+
exports[`babel-plugin-jest-hoist 5. required \`jest\` within \`jest\`: 5. required \`jest\` within \`jest\` 1`] = `
102+
103+
const {jest} = require('@jest/globals');
104+
105+
jest.mock('some-module', () => {
106+
jest.requireActual('some-module');
107+
});
100108
101109
110+
↓ ↓ ↓ ↓ ↓ ↓
111+
112+
const {jest} = require('@jest/globals');
113+
jest.mock('some-module', () => {
114+
jest.requireActual('some-module');
115+
});
116+
102117
`;
103118

104-
exports[`babel-plugin-jest-hoist imported jest.mock within jest.mock: imported jest.mock within jest.mock 1`] = `
119+
exports[`babel-plugin-jest-hoist 6. imported jest.mock within jest.mock: 6. imported jest.mock within jest.mock 1`] = `
105120
106121
import {jest} from '@jest/globals';
107122
108123
jest.mock('some-module', () => {
109124
jest.mock('some-module');
110125
});
111126
127+
112128
↓ ↓ ↓ ↓ ↓ ↓
113129
114130
_getJestObj().mock('some-module', () => {
@@ -121,112 +137,96 @@ function _getJestObj() {
121137
}
122138
import {jest} from '@jest/globals';
123139
124-
125140
`;
126141

127-
exports[`babel-plugin-jest-hoist imported jest.requireActual in jest.mock: imported jest.requireActual in jest.mock 1`] = `
128-
129-
import {jest} from '@jest/globals';
142+
exports[`babel-plugin-jest-hoist 7. global jest.mock within jest.mock: 7. global jest.mock within jest.mock 1`] = `
130143
131144
jest.mock('some-module', () => {
132-
jest.requireActual('some-module');
145+
jest.mock('some-module');
133146
});
134147
135-
jest.requireActual('some-module');
136148
137149
↓ ↓ ↓ ↓ ↓ ↓
138150
139151
_getJestObj().mock('some-module', () => {
140-
_getJestObj().requireActual('some-module');
152+
_getJestObj().mock('some-module');
141153
});
142154
function _getJestObj() {
143155
const {jest} = require('@jest/globals');
144156
_getJestObj = () => jest;
145157
return jest;
146158
}
147-
import {jest} from '@jest/globals';
148-
jest.requireActual('some-module');
149-
150159
151160
`;
152161

153-
exports[`babel-plugin-jest-hoist required \`jest\` within \`jest\`: required \`jest\` within \`jest\` 1`] = `
162+
exports[`babel-plugin-jest-hoist 8. imported jest.requireActual in jest.mock: 8. imported jest.requireActual in jest.mock 1`] = `
154163
155-
const {jest} = require('@jest/globals');
156-
157-
jest.mock('some-module', () => {
158-
jest.requireActual('some-module');
159-
});
160-
161-
↓ ↓ ↓ ↓ ↓ ↓
164+
import {jest} from '@jest/globals';
162165
163-
const {jest} = require('@jest/globals');
164166
jest.mock('some-module', () => {
165167
jest.requireActual('some-module');
166168
});
167169
170+
jest.requireActual('some-module');
168171
169-
`;
170-
171-
exports[`babel-plugin-jest-hoist top level mocking: top level mocking 1`] = `
172-
173-
require('x');
174-
175-
jest.enableAutomock();
176-
jest.disableAutomock();
177172
178173
↓ ↓ ↓ ↓ ↓ ↓
179174
180-
_getJestObj().enableAutomock();
181-
_getJestObj().disableAutomock();
175+
_getJestObj().mock('some-module', () => {
176+
_getJestObj().requireActual('some-module');
177+
});
182178
function _getJestObj() {
183179
const {jest} = require('@jest/globals');
184180
_getJestObj = () => jest;
185181
return jest;
186182
}
187-
require('x');
188-
183+
import {jest} from '@jest/globals';
184+
jest.requireActual('some-module');
189185
190186
`;
191187

192-
exports[`babel-plugin-jest-hoist within a block with no siblings: within a block with no siblings 1`] = `
188+
exports[`babel-plugin-jest-hoist 9. global jest.requireActual in jest.mock: 9. global jest.requireActual in jest.mock 1`] = `
193189
194-
beforeEach(() => {
195-
jest.mock('someNode');
190+
jest.mock('some-module', () => {
191+
jest.requireActual('some-module');
196192
});
197193
194+
jest.requireActual('some-module');
195+
196+
198197
↓ ↓ ↓ ↓ ↓ ↓
199198
199+
_getJestObj().mock('some-module', () => {
200+
_getJestObj().requireActual('some-module');
201+
});
200202
function _getJestObj() {
201203
const {jest} = require('@jest/globals');
202204
_getJestObj = () => jest;
203205
return jest;
204206
}
205-
beforeEach(() => {
206-
_getJestObj().mock('someNode');
207-
});
208-
207+
jest.requireActual('some-module');
209208
210209
`;
211210

212-
exports[`babel-plugin-jest-hoist within a block: within a block 1`] = `
211+
exports[`babel-plugin-jest-hoist 10. TS typeof usage in jest.mock: 10. TS typeof usage in jest.mock 1`] = `
213212
214-
beforeEach(() => {
215-
require('x');
216-
jest.mock('someNode');
213+
jest.mock('some-module', () => {
214+
const actual = jest.requireActual('some-module');
215+
216+
return jest.fn<typeof actual.method>();
217217
});
218218
219+
219220
↓ ↓ ↓ ↓ ↓ ↓
220221
222+
_getJestObj().mock('some-module', () => {
223+
const actual = jest.requireActual('some-module');
224+
return jest.fn();
225+
});
221226
function _getJestObj() {
222227
const {jest} = require('@jest/globals');
223228
_getJestObj = () => jest;
224229
return jest;
225230
}
226-
beforeEach(() => {
227-
_getJestObj().mock('someNode');
228-
require('x');
229-
});
230-
231231
232232
`;

0 commit comments

Comments
 (0)