diff --git a/packages/jest-haste-map/src/index.js b/packages/jest-haste-map/src/index.js index da7015cb170d..6d5f510dc8e8 100644 --- a/packages/jest-haste-map/src/index.js +++ b/packages/jest-haste-map/src/index.js @@ -305,8 +305,10 @@ class HasteMap extends EventEmitter { map[id] = Object.create(null); } const moduleMap = map[id]; - const platform = getPlatformExtension(module[H.PATH]) || - H.GENERIC_PLATFORM; + const platform = getPlatformExtension( + module[H.PATH], + this._options.platforms, + ) || H.GENERIC_PLATFORM; const existingModule = moduleMap[platform]; if (existingModule && existingModule[H.PATH] !== module[H.PATH]) { const message = `jest-haste-map: @providesModule naming collision:\n` + diff --git a/packages/jest-haste-map/src/lib/getPlatformExtension.js b/packages/jest-haste-map/src/lib/getPlatformExtension.js index fa211d075c64..f1b82e92abbb 100644 --- a/packages/jest-haste-map/src/lib/getPlatformExtension.js +++ b/packages/jest-haste-map/src/lib/getPlatformExtension.js @@ -17,13 +17,20 @@ const SUPPORTED_PLATFORM_EXTS = { }; // Extract platform extension: index.ios.js -> ios -function getPlatformExtension(file: string): ?string { +function getPlatformExtension( + file: string, + platforms?: Array, +): ?string { const last = file.lastIndexOf('.'); const secondToLast = file.lastIndexOf('.', last - 1); if (secondToLast === -1) { return null; } const platform = file.substring(secondToLast + 1, last); + // If an overriding platform array is passed, check that first + if (platforms && platforms.includes(platform)) { + return platform; + } return SUPPORTED_PLATFORM_EXTS[platform] ? platform : null; } diff --git a/packages/jest-jasmine2/src/jasmine-light.js b/packages/jest-jasmine2/src/jasmine-light.js index fcd7797811ac..f93b2e7233a2 100644 --- a/packages/jest-jasmine2/src/jasmine-light.js +++ b/packages/jest-jasmine2/src/jasmine-light.js @@ -1654,12 +1654,7 @@ exports.TreeProcessor = function() { return executableIndex === undefined ? defaultMax : executableIndex; } - function segmentChildren( - node, - children, - nodeStats, - executableIndex, - ) { + function segmentChildren(node, children, nodeStats, executableIndex) { let currentSegment = { index: 0, owner: node, diff --git a/packages/jest-matchers/src/asymmetric-matchers.js b/packages/jest-matchers/src/asymmetric-matchers.js index ac0ccbaa5303..b3ad1f32b895 100644 --- a/packages/jest-matchers/src/asymmetric-matchers.js +++ b/packages/jest-matchers/src/asymmetric-matchers.js @@ -130,8 +130,10 @@ class ArrayContaining extends AsymmetricMatcher { ); } - return this.sample.length === 0 || Array.isArray(other) && - this.sample.every(item => other.some(another => equals(item, another))); + return this.sample.length === 0 || + (Array.isArray(other) && + this.sample.every(item => + other.some(another => equals(item, another)))); } toString() {