@wordpress/jest-preset-default 12.48.0 → 12.48.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/jest-preset.js CHANGED
@@ -1,21 +1,13 @@
1
1
  module.exports = {
2
2
  moduleNameMapper: {
3
- '\\.(scss|css)$': require.resolve(
4
- '@wordpress/jest-preset-default/scripts/style-mock.js'
5
- ),
3
+ '\\.(scss|css)$': require.resolve( './scripts/style-mock.js' ),
6
4
  // See https://github.com/facebook/jest/issues/11100#issuecomment-967161978
7
5
  '@eslint/eslintrc': '@eslint/eslintrc/dist/eslintrc-universal.cjs',
8
6
  },
9
7
  modulePaths: [ '<rootDir>' ],
10
- setupFiles: [
11
- require.resolve(
12
- '@wordpress/jest-preset-default/scripts/setup-globals.js'
13
- ),
14
- ],
8
+ setupFiles: [ require.resolve( './scripts/setup-globals.js' ) ],
15
9
  setupFilesAfterEnv: [
16
- require.resolve(
17
- '@wordpress/jest-preset-default/scripts/setup-test-framework.js'
18
- ),
10
+ require.resolve( './scripts/setup-test-framework.js' ),
19
11
  ],
20
12
  testEnvironment: 'jsdom',
21
13
  testMatch: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/jest-preset-default",
3
- "version": "12.48.0",
3
+ "version": "12.48.1",
4
4
  "description": "Default Jest preset for WordPress development.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,8 +31,8 @@
31
31
  ],
32
32
  "main": "index.js",
33
33
  "dependencies": {
34
- "@wordpress/jest-console": "^8.48.0",
35
- "babel-jest": "29.7.0"
34
+ "@wordpress/jest-console": "^8.48.1",
35
+ "babel-jest": "^29.7.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@babel/core": ">=7",
@@ -41,5 +41,5 @@
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  },
44
- "gitHead": "e7856693aeb4e2522d13608cd32c994e4a97cb9c"
44
+ "gitHead": "99df7432c5c7cb83ba41146fd1f57f3c19004305"
45
45
  }
@@ -2,42 +2,50 @@
2
2
  // eslint-disable-next-line @wordpress/wp-global-usage
3
3
  globalThis.SCRIPT_DEBUG = true;
4
4
 
5
- // These are necessary to load TinyMCE successfully.
6
- global.window.tinyMCEPreInit = {
7
- // Without this, TinyMCE tries to determine its URL by looking at the
8
- // <script> tag where it was loaded from, which of course fails here.
9
- baseURL: 'about:blank',
10
- };
5
+ // The remaining globals all hang off `window`, which only exists when the test
6
+ // is using a DOM environment (jsdom). Skip them when running under
7
+ // `@jest-environment node`.
8
+ if ( typeof global.window !== 'undefined' ) {
9
+ // These are necessary to load TinyMCE successfully.
10
+ global.window.tinyMCEPreInit = {
11
+ // Without this, TinyMCE tries to determine its URL by looking at the
12
+ // <script> tag where it was loaded from, which of course fails here.
13
+ baseURL: 'about:blank',
14
+ };
11
15
 
12
- global.window.setImmediate = function ( callback ) {
13
- return setTimeout( callback, 0 );
14
- };
16
+ global.window.setImmediate = function ( callback ) {
17
+ return setTimeout( callback, 0 );
18
+ };
15
19
 
16
- // Ignoring `options` argument since we unconditionally schedule this ASAP.
17
- global.window.requestIdleCallback = function requestIdleCallback( callback ) {
18
- const start = Date.now();
20
+ // Ignoring `options` argument since we unconditionally schedule this ASAP.
21
+ global.window.requestIdleCallback = function requestIdleCallback(
22
+ callback
23
+ ) {
24
+ const start = Date.now();
19
25
 
20
- return setTimeout(
21
- () =>
22
- callback( {
23
- didTimeout: false,
24
- timeRemaining: () => Math.max( 0, 50 - ( Date.now() - start ) ),
25
- } ),
26
- 0
27
- );
28
- };
26
+ return setTimeout(
27
+ () =>
28
+ callback( {
29
+ didTimeout: false,
30
+ timeRemaining: () =>
31
+ Math.max( 0, 50 - ( Date.now() - start ) ),
32
+ } ),
33
+ 0
34
+ );
35
+ };
29
36
 
30
- global.window.cancelIdleCallback = function cancelIdleCallback( handle ) {
31
- return clearTimeout( handle );
32
- };
37
+ global.window.cancelIdleCallback = function cancelIdleCallback( handle ) {
38
+ return clearTimeout( handle );
39
+ };
33
40
 
34
- global.window.matchMedia = () => ( {
35
- matches: false,
36
- addListener: () => {},
37
- addEventListener: () => {},
38
- removeListener: () => {},
39
- removeEventListener: () => {},
40
- } );
41
+ global.window.matchMedia = () => ( {
42
+ matches: false,
43
+ addListener: () => {},
44
+ addEventListener: () => {},
45
+ removeListener: () => {},
46
+ removeEventListener: () => {},
47
+ } );
41
48
 
42
- // UserSettings global.
43
- global.window.userSettings = { uid: 1 };
49
+ // UserSettings global.
50
+ global.window.userSettings = { uid: 1 };
51
+ }