Skip to content

Commit

Permalink
Testing: Replace require.requireActual with jest.requireActual (#22370)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed May 15, 2020
1 parent bab1bc8 commit 01d2de2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/disabled/test/index.js
Expand Up @@ -14,7 +14,7 @@ import { Component } from '@wordpress/element';
import Disabled from '../';

jest.mock( '@wordpress/dom', () => {
const focus = require.requireActual( '../../../../dom/src' ).focus;
const focus = jest.requireActual( '../../../../dom/src' ).focus;

return {
focus: {
Expand Down
Expand Up @@ -15,7 +15,7 @@ import withGlobalEvents from '../';
import Listener from '../listener';

jest.mock( '../listener', () => {
const ActualListener = require.requireActual( '../listener' ).default;
const ActualListener = jest.requireActual( '../listener' ).default;

return class extends ActualListener {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-preset-default/scripts/setup-test-framework.js
Expand Up @@ -7,12 +7,12 @@ require( '@wordpress/jest-console' );
let mockEnzymeSetup = false;

jest.mock( 'enzyme', () => {
const actualEnzyme = require.requireActual( 'enzyme' );
const actualEnzyme = jest.requireActual( 'enzyme' );
if ( ! mockEnzymeSetup ) {
mockEnzymeSetup = true;

// configure enzyme 3 for React, from docs: http://airbnb.io/enzyme/docs/installation/index.html
const Adapter = require.requireActual( 'enzyme-adapter-react-16' );
const Adapter = jest.requireActual( 'enzyme-adapter-react-16' );
actualEnzyme.configure( { adapter: new Adapter() } );
}
return actualEnzyme;
Expand Down
2 changes: 1 addition & 1 deletion packages/priority-queue/src/test/index.js
Expand Up @@ -5,7 +5,7 @@ import { createQueue } from '../';
import requestIdleCallback from '../request-idle-callback';

jest.mock( '../request-idle-callback', () => {
const emitter = new ( require.requireActual( 'events' ).EventEmitter )();
const emitter = new ( jest.requireActual( 'events' ).EventEmitter )();

return Object.assign(
( callback ) =>
Expand Down
4 changes: 2 additions & 2 deletions packages/scripts/utils/test/index.js
Expand Up @@ -14,14 +14,14 @@ import {
} from '../process';

jest.mock( '../package', () => {
const module = require.requireActual( '../package' );
const module = jest.requireActual( '../package' );

jest.spyOn( module, 'getPackagePath' );

return module;
} );
jest.mock( '../process', () => {
const module = require.requireActual( '../process' );
const module = jest.requireActual( '../process' );

jest.spyOn( module, 'exit' );
jest.spyOn( module, 'getArgsFromCLI' );
Expand Down
2 changes: 1 addition & 1 deletion packages/url/src/test/index.native.js
Expand Up @@ -4,7 +4,7 @@
import './index.test';

jest.mock( './fixtures/wpt-data.json', () => {
const data = require.requireActual( './fixtures/wpt-data.json' );
const data = jest.requireActual( './fixtures/wpt-data.json' );

/**
* Test items to exclude by input. Ideally this should be empty, but are
Expand Down

0 comments on commit 01d2de2

Please sign in to comment.