Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dd267eb

Browse filesBrowse files
committed
Ensure .ts test files use local immutable module
1 parent feaf0fc commit dd267eb
Copy full SHA for dd267eb

File tree

Expand file treeCollapse file tree

1 file changed

+13
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-7
lines changed

‎resources/jestPreprocessor.js

Copy file name to clipboardExpand all lines: resources/jestPreprocessor.js
+13-7Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,23 @@ function compileTypeScript(filePath) {
5252
return fs.readFileSync(outputPath, {encoding: 'utf8'});
5353
}
5454

55+
function withLocalImmutable(jsSrc) {
56+
return jsSrc.replace(
57+
/require\('immutable/g,
58+
"require('" + path.relative(path.dirname(filePath), process.cwd())
59+
);
60+
}
61+
5562
module.exports = {
5663
process: function(src, filePath) {
5764
if (filePath.match(/\.ts$/) && !filePath.match(/\.d\.ts$/)) {
58-
return compileTypeScript(filePath);
59-
} else if (filePath.match(/\.js$/) && ~filePath.indexOf('/__tests__/')) {
60-
var result = react.transform(src, {harmony: true}).replace(
61-
/require\('immutable/g,
62-
"require('" + path.relative(path.dirname(filePath), process.cwd())
63-
);
64-
return result;
65+
return withLocalImmutable(compileTypeScript(filePath));
6566
}
67+
68+
if (filePath.match(/\.js$/) && ~filePath.indexOf('/__tests__/')) {
69+
return withLocalImmutable(react.transform(src, {harmony: true}));
70+
}
71+
6672
return src;
6773
}
6874
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.