|
| 1 | +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing |
| 2 | + |
| 3 | +exports[`babel 7 babel-plugin-jest-hoist 1. automatic react runtime: 1. automatic react runtime 1`] = ` |
| 4 | +
|
| 5 | +jest.mock('./App', () => () => <div>Hello world</div>); |
| 6 | +
|
| 7 | +
|
| 8 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 9 | +
|
| 10 | +var _jsxFileName = '/root/project/src/file.js'; |
| 11 | +_getJestObj().mock( |
| 12 | + './App', |
| 13 | + () => () => |
| 14 | + /*#__PURE__*/ _jsxDEV( |
| 15 | + 'div', |
| 16 | + { |
| 17 | + children: 'Hello world', |
| 18 | + }, |
| 19 | + void 0, |
| 20 | + false, |
| 21 | + { |
| 22 | + fileName: _jsxFileName, |
| 23 | + lineNumber: 1, |
| 24 | + columnNumber: 32, |
| 25 | + }, |
| 26 | + this, |
| 27 | + ), |
| 28 | +); |
| 29 | +import {jsxDEV as _jsxDEV} from 'react/jsx-dev-runtime'; |
| 30 | +function _getJestObj() { |
| 31 | + const {jest} = require('@jest/globals'); |
| 32 | + _getJestObj = () => jest; |
| 33 | + return jest; |
| 34 | +} |
| 35 | +
|
| 36 | +`; |
| 37 | + |
| 38 | +exports[`babel 7 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'); |
| 56 | +
|
| 57 | +`; |
| 58 | + |
| 59 | +exports[`babel 7 babel-plugin-jest-hoist 3. within a block: 3. within a block 1`] = ` |
| 60 | +
|
| 61 | +beforeEach(() => { |
| 62 | + require('x'); |
| 63 | + jest.mock('someNode'); |
| 64 | +}); |
| 65 | +
|
| 66 | +
|
| 67 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 68 | +
|
| 69 | +function _getJestObj() { |
| 70 | + const {jest} = require('@jest/globals'); |
| 71 | + _getJestObj = () => jest; |
| 72 | + return jest; |
| 73 | +} |
| 74 | +beforeEach(() => { |
| 75 | + _getJestObj().mock('someNode'); |
| 76 | + require('x'); |
| 77 | +}); |
| 78 | +
|
| 79 | +`; |
| 80 | + |
| 81 | +exports[`babel 7 babel-plugin-jest-hoist 4. within a block with no siblings: 4. within a block with no siblings 1`] = ` |
| 82 | +
|
| 83 | +beforeEach(() => { |
| 84 | + jest.mock('someNode'); |
| 85 | +}); |
| 86 | +
|
| 87 | +
|
| 88 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 89 | +
|
| 90 | +function _getJestObj() { |
| 91 | + const {jest} = require('@jest/globals'); |
| 92 | + _getJestObj = () => jest; |
| 93 | + return jest; |
| 94 | +} |
| 95 | +beforeEach(() => { |
| 96 | + _getJestObj().mock('someNode'); |
| 97 | +}); |
| 98 | +
|
| 99 | +`; |
| 100 | + |
| 101 | +exports[`babel 7 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 | +}); |
| 108 | +
|
| 109 | +
|
| 110 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 111 | +
|
| 112 | +const {jest} = require('@jest/globals'); |
| 113 | +jest.mock('some-module', () => { |
| 114 | + jest.requireActual('some-module'); |
| 115 | +}); |
| 116 | +
|
| 117 | +`; |
| 118 | + |
| 119 | +exports[`babel 7 babel-plugin-jest-hoist 6. imported jest.mock within jest.mock: 6. imported jest.mock within jest.mock 1`] = ` |
| 120 | +
|
| 121 | +import {jest} from '@jest/globals'; |
| 122 | +
|
| 123 | +jest.mock('some-module', () => { |
| 124 | + jest.mock('some-module'); |
| 125 | +}); |
| 126 | +
|
| 127 | +
|
| 128 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 129 | +
|
| 130 | +_getJestObj().mock('some-module', () => { |
| 131 | + _getJestObj().mock('some-module'); |
| 132 | +}); |
| 133 | +function _getJestObj() { |
| 134 | + const {jest} = require('@jest/globals'); |
| 135 | + _getJestObj = () => jest; |
| 136 | + return jest; |
| 137 | +} |
| 138 | +import {jest} from '@jest/globals'; |
| 139 | +
|
| 140 | +`; |
| 141 | + |
| 142 | +exports[`babel 7 babel-plugin-jest-hoist 7. global jest.mock within jest.mock: 7. global jest.mock within jest.mock 1`] = ` |
| 143 | +
|
| 144 | +jest.mock('some-module', () => { |
| 145 | + jest.mock('some-module'); |
| 146 | +}); |
| 147 | +
|
| 148 | +
|
| 149 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 150 | +
|
| 151 | +_getJestObj().mock('some-module', () => { |
| 152 | + _getJestObj().mock('some-module'); |
| 153 | +}); |
| 154 | +function _getJestObj() { |
| 155 | + const {jest} = require('@jest/globals'); |
| 156 | + _getJestObj = () => jest; |
| 157 | + return jest; |
| 158 | +} |
| 159 | +
|
| 160 | +`; |
| 161 | + |
| 162 | +exports[`babel 7 babel-plugin-jest-hoist 8. imported jest.requireActual in jest.mock: 8. imported jest.requireActual in jest.mock 1`] = ` |
| 163 | +
|
| 164 | +import {jest} from '@jest/globals'; |
| 165 | +
|
| 166 | +jest.mock('some-module', () => { |
| 167 | + jest.requireActual('some-module'); |
| 168 | +}); |
| 169 | +
|
| 170 | +jest.requireActual('some-module'); |
| 171 | +
|
| 172 | +
|
| 173 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 174 | +
|
| 175 | +_getJestObj().mock('some-module', () => { |
| 176 | + _getJestObj().requireActual('some-module'); |
| 177 | +}); |
| 178 | +function _getJestObj() { |
| 179 | + const {jest} = require('@jest/globals'); |
| 180 | + _getJestObj = () => jest; |
| 181 | + return jest; |
| 182 | +} |
| 183 | +import {jest} from '@jest/globals'; |
| 184 | +jest.requireActual('some-module'); |
| 185 | +
|
| 186 | +`; |
| 187 | + |
| 188 | +exports[`babel 7 babel-plugin-jest-hoist 9. global jest.requireActual in jest.mock: 9. global jest.requireActual in jest.mock 1`] = ` |
| 189 | +
|
| 190 | +jest.mock('some-module', () => { |
| 191 | + jest.requireActual('some-module'); |
| 192 | +}); |
| 193 | +
|
| 194 | +jest.requireActual('some-module'); |
| 195 | +
|
| 196 | +
|
| 197 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 198 | +
|
| 199 | +_getJestObj().mock('some-module', () => { |
| 200 | + _getJestObj().requireActual('some-module'); |
| 201 | +}); |
| 202 | +function _getJestObj() { |
| 203 | + const {jest} = require('@jest/globals'); |
| 204 | + _getJestObj = () => jest; |
| 205 | + return jest; |
| 206 | +} |
| 207 | +jest.requireActual('some-module'); |
| 208 | +
|
| 209 | +`; |
| 210 | + |
| 211 | +exports[`babel 7 babel-plugin-jest-hoist 10. TS typeof usage in jest.mock: 10. TS typeof usage in jest.mock 1`] = ` |
| 212 | +
|
| 213 | +jest.mock('some-module', () => { |
| 214 | + const actual = jest.requireActual('some-module'); |
| 215 | +
|
| 216 | + return jest.fn<typeof actual.method>(); |
| 217 | +}); |
| 218 | +
|
| 219 | +
|
| 220 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 221 | +
|
| 222 | +_getJestObj().mock('some-module', () => { |
| 223 | + const actual = jest.requireActual('some-module'); |
| 224 | + return jest.fn(); |
| 225 | +}); |
| 226 | +function _getJestObj() { |
| 227 | + const {jest} = require('@jest/globals'); |
| 228 | + _getJestObj = () => jest; |
| 229 | + return jest; |
| 230 | +} |
| 231 | +
|
| 232 | +`; |
| 233 | + |
| 234 | +exports[`babel 7 babel-plugin-jest-hoist 11. jest.spyOn call on the imported module: 11. jest.spyOn call on the imported module 1`] = ` |
| 235 | +
|
| 236 | +jest.mock('some-module', () => { |
| 237 | + const module = jest.requireActual('some-module'); |
| 238 | + jest.spyOn(module, 'add'); |
| 239 | + return module; |
| 240 | +}); |
| 241 | +
|
| 242 | +
|
| 243 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 244 | +
|
| 245 | +_getJestObj().mock('some-module', () => { |
| 246 | + const module = jest.requireActual('some-module'); |
| 247 | + _getJestObj().spyOn(module, 'add'); |
| 248 | + return module; |
| 249 | +}); |
| 250 | +function _getJestObj() { |
| 251 | + const {jest} = require('@jest/globals'); |
| 252 | + _getJestObj = () => jest; |
| 253 | + return jest; |
| 254 | +} |
| 255 | +
|
| 256 | +`; |
| 257 | + |
| 258 | +exports[`babel 7 babel-plugin-jest-hoist 12. jest.spyOn call in class constructor: 12. jest.spyOn call in class constructor 1`] = ` |
| 259 | +
|
| 260 | +jest.mock('some-module', () => { |
| 261 | + const Actual = jest.requireActual('some-module'); |
| 262 | + return class Mocked extends Actual { |
| 263 | + constructor() { |
| 264 | + super(); |
| 265 | + jest.spyOn(this, 'add'); |
| 266 | + } |
| 267 | + }; |
| 268 | +}); |
| 269 | +
|
| 270 | +
|
| 271 | + ↓ ↓ ↓ ↓ ↓ ↓ |
| 272 | +
|
| 273 | +_getJestObj().mock('some-module', () => { |
| 274 | + const Actual = jest.requireActual('some-module'); |
| 275 | + return class Mocked extends Actual { |
| 276 | + constructor() { |
| 277 | + super(); |
| 278 | + _getJestObj().spyOn(this, 'add'); |
| 279 | + } |
| 280 | + }; |
| 281 | +}); |
| 282 | +function _getJestObj() { |
| 283 | + const {jest} = require('@jest/globals'); |
| 284 | + _getJestObj = () => jest; |
| 285 | + return jest; |
| 286 | +} |
| 287 | +
|
| 288 | +`; |
0 commit comments