Skip to content

Commit 9bb437b

Browse files
committed
Fix mobile unit tests
1 parent de923e0 commit 9bb437b

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

test/native/jest.config.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,50 @@ if ( process.env.TEST_RN_PLATFORM ) {
1313
console.log( 'Setting RN platform to: default (' + defaultPlatform + ')' );
1414
}
1515

16-
const configPath = 'test/native';
17-
1816
const transpiledPackageNames = glob( '../../packages/*/src/index.{js,ts}' ).map(
1917
( fileName ) => fileName.split( '/' )[ 3 ]
2018
);
2119

2220
module.exports = {
2321
verbose: true,
24-
rootDir: '../../',
22+
rootDir: '.',
23+
roots: [ '<rootDir>/../..' ],
2524
// Automatically clear mock calls and instances between every test.
2625
clearMocks: true,
2726
preset: 'react-native',
28-
setupFiles: [ '<rootDir>/' + configPath + '/setup.js' ],
29-
setupFilesAfterEnv: [ '<rootDir>/' + configPath + '/setup-after-env.js' ],
27+
setupFiles: [ '<rootDir>/setup.js' ],
28+
setupFilesAfterEnv: [ '<rootDir>/setup-after-env.js' ],
3029
testMatch: [
31-
'**/test/!(helper)*.native.[jt]s?(x)',
32-
'<rootDir>/packages/react-native-*/**/?(*.)+(spec|test).[jt]s?(x)',
30+
'<rootDir>/../../**/test/!(helper)*.native.[jt]s?(x)',
31+
'<rootDir>/../../packages/react-native-*/**/?(*.)+(spec|test).[jt]s?(x)',
3332
],
3433
testPathIgnorePatterns: [
3534
'/node_modules/',
3635
'/__device-tests__/',
37-
'<rootDir>/.*/build/',
38-
'<rootDir>/.*/build-module/',
36+
'<rootDir>/../../.*/build/',
37+
'<rootDir>/../../.*/build-module/',
3938
],
4039
testEnvironmentOptions: {
4140
url: 'http://localhost/',
4241
},
42+
resolver: '<rootDir>/../../test/unit/scripts/resolver.js',
4343
// Add the `Libraries/Utilities` subfolder to the module directories, otherwise haste/jest doesn't find Platform.js on Travis,
4444
// 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.
4545
moduleDirectories: [
46-
'node_modules/react-native/Libraries/Utilities',
47-
'node_modules',
46+
'../../node_modules/react-native/Libraries/Utilities',
47+
'../../node_modules',
4848
],
4949
moduleNameMapper: {
5050
// Mock the CSS modules. See https://facebook.github.io/jest/docs/en/webpack.html#handling-static-assets
51-
'\\.(scss)$': '<rootDir>/' + configPath + '/__mocks__/styleMock.js',
51+
'\\.(scss)$': '<rootDir>/__mocks__/styleMock.js',
5252
'\\.(eot|otf|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
53-
'<rootDir>/' + configPath + '/__mocks__/fileMock.js',
53+
'<rootDir>/__mocks__/fileMock.js',
5454
[ `@wordpress\\/(${ transpiledPackageNames.join( '|' ) })$` ]:
55-
'<rootDir>/packages/$1/src',
56-
'test/helpers$': '<rootDir>/test/native/helpers.js',
55+
'<rootDir>/../../packages/$1/src',
56+
'test/helpers$': '<rootDir>/../../test/native/helpers.js',
5757
},
5858
modulePathIgnorePatterns: [
59-
'<rootDir>/packages/react-native-editor/node_modules',
59+
'<rootDir>/../../packages/react-native-editor/node_modules',
6060
],
6161
haste: {
6262
defaultPlatform: rnPlatform,

test/unit/scripts/resolver.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ module.exports = ( path, options ) => {
2323
if (
2424
pkg.name === 'uuid' ||
2525
pkg.name === 'react-colorful' ||
26-
pkg.name === '@eslint/eslintrc'
26+
pkg.name === '@eslint/eslintrc' ||
27+
pkg.name === 'expect'
2728
) {
2829
delete pkg.exports;
2930
delete pkg.module;

0 commit comments

Comments
 (0)