Skip to content

Commit

Permalink
Removed default support for @providesModule
Browse files Browse the repository at this point in the history
  • Loading branch information
rubennorte committed May 1, 2018
1 parent 4c75933 commit 954713a
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 407 deletions.
1 change: 0 additions & 1 deletion packages/jest-haste-map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"dependencies": {
"fb-watchman": "^2.0.0",
"graceful-fs": "^4.1.11",
"jest-docblock": "^22.4.0",
"jest-serializer": "^22.4.0",
"jest-worker": "^22.2.2",
"micromatch": "^2.3.11",
Expand Down
116 changes: 105 additions & 11 deletions packages/jest-haste-map/src/__tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,25 +1,119 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HasteMap builds a haste map on a fresh cache with SHA-1s uses watchman: false 1`] = `
Object {
"/fruits/Banana.js": Array [
"Banana",
32,
1,
Array [
"Strawberry",
],
"5ed33593647e9ed632d8133a91b2dbef416a5d77",
],
"/fruits/Pear.js": Array [
"Pear",
32,
1,
Array [
"Banana",
"Strawberry",
],
"210aa3531d1646b6469d88d80168417f8dd08c7f",
],
"/fruits/Strawberry.js": Array [
"Strawberry",
32,
1,
Array [],
"65a371cc1a610b7cad68798d6d4ff5a941f837b8",
],
"/fruits/__mocks__/Pear.js": Array [
"",
32,
1,
Array [
"Melon",
],
"e0753bafe7b1f7a460fe8af9925f15e79960bb20",
],
"/vegetables/Melon.js": Array [
"Melon",
32,
1,
Array [],
"ff9c3f399d8f8bc7e67f99d065efff6570ce9347",
],
}
`;

exports[`HasteMap builds a haste map on a fresh cache with SHA-1s uses watchman: true 1`] = `
Object {
"/fruits/Banana.js": Array [
"Banana",
32,
1,
Array [
"Strawberry",
],
"5ed33593647e9ed632d8133a91b2dbef416a5d77",
],
"/fruits/Pear.js": Array [
"Pear",
32,
1,
Array [
"Banana",
"Strawberry",
],
"210aa3531d1646b6469d88d80168417f8dd08c7f",
],
"/fruits/Strawberry.js": Array [
"Strawberry",
32,
1,
Array [],
"65a371cc1a610b7cad68798d6d4ff5a941f837b8",
],
"/fruits/__mocks__/Pear.js": Array [
"",
32,
1,
Array [
"Melon",
],
"e0753bafe7b1f7a460fe8af9925f15e79960bb20",
],
"/vegetables/Melon.js": Array [
"Melon",
32,
1,
Array [],
"ff9c3f399d8f8bc7e67f99d065efff6570ce9347",
],
}
`;

exports[`HasteMap file system changes processing recovery from duplicate module IDs recovers when the most recent duplicate is fixed 1`] = `
"The name \`Pear\` was looked up in the Haste module map. It cannot be resolved, because there exists several different files, or packages, that provide a module for that particular name and platform. The platform is generic (no extension). You must delete or blacklist files until there remains only one of these:
* \`/fruits/blueberry.js\` (module)
* \`/fruits/pear.js\` (module)
* \`/fruits/Pear.js\` (module)
* \`/fruits/another/Pear.js\` (module)
"
`;

exports[`HasteMap file system changes processing recovery from duplicate module IDs recovers when the oldest version of the duplicates is fixed 1`] = `
"The name \`Pear\` was looked up in the Haste module map. It cannot be resolved, because there exists several different files, or packages, that provide a module for that particular name and platform. The platform is generic (no extension). You must delete or blacklist files until there remains only one of these:
* \`/fruits/blueberry.js\` (module)
* \`/fruits/pear.js\` (module)
* \`/fruits/Pear.js\` (module)
* \`/fruits/another/Pear.js\` (module)
"
`;

exports[`HasteMap throws on duplicate module ids if "throwOnModuleCollision" is set to true 1`] = `
[Error: jest-haste-map: @providesModule naming collision:
Duplicate module name: Strawberry
Paths: /fruits/raspberry.js collides with /fruits/strawberry.js
Paths: /fruits/another/Strawberry.js collides with /fruits/Strawberry.js
This error is caused by a @providesModule declaration with the same name across two different files.]
`;
Expand All @@ -32,22 +126,22 @@ exports[`HasteMap tries to crawl using node as a fallback 1`] = `

exports[`HasteMap warns on duplicate mock files 1`] = `
"jest-haste-map: duplicate manual mock found:
Module name: subdir/blueberry
Duplicate Mock path: /fruits2/__mocks__/subdir/blueberry.js
Module name: blueberry
Duplicate Mock path: /fruits/dir2/__mocks__/blueberry.js
This warning is caused by two manual mock files with the same file name.
Jest will use the mock file found in:
/fruits2/__mocks__/subdir/blueberry.js
/fruits/dir2/__mocks__/blueberry.js
Please delete one of the following two files:
/fruits1/__mocks__/subdir/blueberry.js
/fruits2/__mocks__/subdir/blueberry.js
/fruits/dir1/__mocks__/blueberry.js
/fruits/dir2/__mocks__/blueberry.js
"
`;

exports[`HasteMap warns on duplicate module ids 1`] = `
"jest-haste-map: @providesModule naming collision:
Duplicate module name: Strawberry
Paths: /fruits/raspberry.js collides with /fruits/strawberry.js
Paths: /fruits/another/Strawberry.js collides with /fruits/Strawberry.js
This warning is caused by a @providesModule declaration with the same name across two different files."
`;
8 changes: 7 additions & 1 deletion packages/jest-haste-map/src/__tests__/haste_impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

module.exports = {
getHasteName(path) {
return path.substr(path.lastIndexOf('/') + 1).replace(/\.js$/, '');
if (path.includes('__mocks__') || path.includes('NoHaste')) {
return undefined;
}

return path
.substr(path.lastIndexOf('/') + 1)
.replace(/(\.(android|ios))?\.js$/, '');
},
};
Loading

0 comments on commit 954713a

Please sign in to comment.