Skip to content

Commit

Permalink
Fix mobile unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnajdr committed Jan 27, 2023
1 parent de923e0 commit 9bb437b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
32 changes: 16 additions & 16 deletions test/native/jest.config.js
Expand Up @@ -13,50 +13,50 @@ if ( process.env.TEST_RN_PLATFORM ) {
console.log( 'Setting RN platform to: default (' + defaultPlatform + ')' );
}

const configPath = 'test/native';

const transpiledPackageNames = glob( '../../packages/*/src/index.{js,ts}' ).map(
( fileName ) => fileName.split( '/' )[ 3 ]
);

module.exports = {
verbose: true,
rootDir: '../../',
rootDir: '.',
roots: [ '<rootDir>/../..' ],
// Automatically clear mock calls and instances between every test.
clearMocks: true,
preset: 'react-native',
setupFiles: [ '<rootDir>/' + configPath + '/setup.js' ],
setupFilesAfterEnv: [ '<rootDir>/' + configPath + '/setup-after-env.js' ],
setupFiles: [ '<rootDir>/setup.js' ],
setupFilesAfterEnv: [ '<rootDir>/setup-after-env.js' ],
testMatch: [
'**/test/!(helper)*.native.[jt]s?(x)',
'<rootDir>/packages/react-native-*/**/?(*.)+(spec|test).[jt]s?(x)',
'<rootDir>/../../**/test/!(helper)*.native.[jt]s?(x)',
'<rootDir>/../../packages/react-native-*/**/?(*.)+(spec|test).[jt]s?(x)',
],
testPathIgnorePatterns: [
'/node_modules/',
'/__device-tests__/',
'<rootDir>/.*/build/',
'<rootDir>/.*/build-module/',
'<rootDir>/../../.*/build/',
'<rootDir>/../../.*/build-module/',
],
testEnvironmentOptions: {
url: 'http://localhost/',
},
resolver: '<rootDir>/../../test/unit/scripts/resolver.js',
// Add the `Libraries/Utilities` subfolder to the module directories, otherwise haste/jest doesn't find Platform.js on Travis,
// and add it first so https://github.com/facebook/react-native/blob/v0.60.0/Libraries/react-native/react-native-implementation.js#L324-L326 doesn't pick up the Platform npm module.
moduleDirectories: [
'node_modules/react-native/Libraries/Utilities',
'node_modules',
'../../node_modules/react-native/Libraries/Utilities',
'../../node_modules',
],
moduleNameMapper: {
// Mock the CSS modules. See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets
'\\.(scss)$': '<rootDir>/' + configPath + '/__mocks__/styleMock.js',
'\\.(scss)$': '<rootDir>/__mocks__/styleMock.js',
'\\.(eot|otf|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/' + configPath + '/__mocks__/fileMock.js',
'<rootDir>/__mocks__/fileMock.js',
[ `@wordpress\\/(${ transpiledPackageNames.join( '|' ) })$` ]:
'<rootDir>/packages/$1/src',
'test/helpers$': '<rootDir>/test/native/helpers.js',
'<rootDir>/../../packages/$1/src',
'test/helpers$': '<rootDir>/../../test/native/helpers.js',
},
modulePathIgnorePatterns: [
'<rootDir>/packages/react-native-editor/node_modules',
'<rootDir>/../../packages/react-native-editor/node_modules',
],
haste: {
defaultPlatform: rnPlatform,
Expand Down
3 changes: 2 additions & 1 deletion test/unit/scripts/resolver.js
Expand Up @@ -23,7 +23,8 @@ module.exports = ( path, options ) => {
if (
pkg.name === 'uuid' ||
pkg.name === 'react-colorful' ||
pkg.name === '@eslint/eslintrc'
pkg.name === '@eslint/eslintrc' ||
pkg.name === 'expect'
) {
delete pkg.exports;
delete pkg.module;
Expand Down

0 comments on commit 9bb437b

Please sign in to comment.