|
12 | 12 |
|
13 | 13 | module.exports = ({template}) => {
|
14 | 14 | const promiseDeclaration = template(`
|
| 15 | + var global = (function() { |
| 16 | + if (typeof globalThis !== 'undefined') { |
| 17 | + return globalThis; |
| 18 | + } else if (typeof global !== 'undefined') { |
| 19 | + return global; |
| 20 | + } else if (typeof self !== 'undefined') { |
| 21 | + return self; |
| 22 | + } else if (typeof window !== 'undefined') { |
| 23 | + return window; |
| 24 | + } else { |
| 25 | + return Function('return this')(); |
| 26 | + } |
| 27 | + }()) |
15 | 28 | var Promise = global[Symbol.for('jest-native-promise')] || global.Promise;
|
16 | 29 | `);
|
17 | 30 | const symbolDeclaration = template(`
|
| 31 | + var global = (function() { |
| 32 | + if (typeof globalThis !== 'undefined') { |
| 33 | + return globalThis; |
| 34 | + } else if (typeof global !== 'undefined') { |
| 35 | + return global; |
| 36 | + } else if (typeof self !== 'undefined') { |
| 37 | + return self; |
| 38 | + } else if (typeof window !== 'undefined') { |
| 39 | + return window; |
| 40 | + } else { |
| 41 | + return Function('return this')(); |
| 42 | + } |
| 43 | + }()) |
18 | 44 | var Symbol = global['jest-symbol-do-not-touch'] || global.Symbol;
|
19 | 45 | `);
|
20 | 46 | const nowDeclaration = template(`
|
| 47 | + var global = (function() { |
| 48 | + if (typeof globalThis !== 'undefined') { |
| 49 | + return globalThis; |
| 50 | + } else if (typeof global !== 'undefined') { |
| 51 | + return global; |
| 52 | + } else if (typeof self !== 'undefined') { |
| 53 | + return self; |
| 54 | + } else if (typeof window !== 'undefined') { |
| 55 | + return window; |
| 56 | + } else { |
| 57 | + return Function('return this')(); |
| 58 | + } |
| 59 | + }()) |
21 | 60 | var jestNow = global[Symbol.for('jest-native-now')] || global.Date.now;
|
22 | 61 | `);
|
23 | 62 | const fsReadFileDeclaration = template(`
|
| 63 | + var global = (function() { |
| 64 | + if (typeof globalThis !== 'undefined') { |
| 65 | + return globalThis; |
| 66 | + } else if (typeof global !== 'undefined') { |
| 67 | + return global; |
| 68 | + } else if (typeof self !== 'undefined') { |
| 69 | + return self; |
| 70 | + } else if (typeof window !== 'undefined') { |
| 71 | + return window; |
| 72 | + } else { |
| 73 | + return Function('return this')(); |
| 74 | + } |
| 75 | + }()) |
24 | 76 | var jestReadFile = global[Symbol.for('jest-native-read-file')] || fs.readFileSync;
|
25 | 77 | `);
|
26 | 78 | const fsWriteFileDeclaration = template(`
|
| 79 | + var global = (function() { |
| 80 | + if (typeof globalThis !== 'undefined') { |
| 81 | + return globalThis; |
| 82 | + } else if (typeof global !== 'undefined') { |
| 83 | + return global; |
| 84 | + } else if (typeof self !== 'undefined') { |
| 85 | + return self; |
| 86 | + } else if (typeof window !== 'undefined') { |
| 87 | + return window; |
| 88 | + } else { |
| 89 | + return Function('return this')(); |
| 90 | + } |
| 91 | + }()) |
27 | 92 | var jestWriteFile = global[Symbol.for('jest-native-write-file')] || fs.writeFileSync;
|
28 | 93 | `);
|
29 | 94 | const fsExistsFileDeclaration = template(`
|
| 95 | + var global = (function() { |
| 96 | + if (typeof globalThis !== 'undefined') { |
| 97 | + return globalThis; |
| 98 | + } else if (typeof global !== 'undefined') { |
| 99 | + return global; |
| 100 | + } else if (typeof self !== 'undefined') { |
| 101 | + return self; |
| 102 | + } else if (typeof window !== 'undefined') { |
| 103 | + return window; |
| 104 | + } else { |
| 105 | + return Function('return this')(); |
| 106 | + } |
| 107 | + }()) |
30 | 108 | var jestExistsFile = global[Symbol.for('jest-native-exists-file')] || fs.existsSync;
|
31 | 109 | `);
|
32 | 110 |
|
|
0 commit comments