-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove unnecessary config * Revert * Add typingTestTransformer * Rename to __tests__ * Rename to __tests__ * Bump scaffold * Add entrypoint --------- Co-authored-by: William Wong <compulim@hotmail.com> Co-authored-by: @compulim <@compulim>
- Loading branch information
1 parent
e99cfe8
commit 3023174
Showing
8 changed files
with
88 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
{ | ||
"testMatch": [ | ||
"**/__tests__/**/*.?([cm])[jt]s?(x)", | ||
"**/?(*.)+(spec|test).?([cm])[tj]s?(x)" | ||
], | ||
"testMatch": ["**/__tests__/**/*.?([cm])[jt]s?(x)", "**/?(*.)+(spec|test).?([cm])[jt]s?(x)"], | ||
"transform": { | ||
"\\.mjsx?$": ["babel-jest"] | ||
"\\.cjsx?$": [ | ||
"babel-jest", | ||
{ | ||
"presets": ["@babel/preset-react"] | ||
} | ||
], | ||
"\\.mjsx?$": [ | ||
"babel-jest", | ||
{ | ||
"presets": [ | ||
"@babel/preset-react", | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"modules": "commonjs", | ||
"targets": "defaults" | ||
} | ||
] | ||
] | ||
} | ||
] | ||
} | ||
} |
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
packages/message-port-rpc/__tests__/__setup__/typingTestTransformer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Notes: to test changes in this file, run "jest" with "--no-cache" argument. | ||
|
||
const run = ({ filename }) => { | ||
const typeScript = require('typescript'); | ||
|
||
function compile(...filenames) { | ||
const program = typeScript.createProgram(filenames, { | ||
allowSyntheticDefaultImports: true, | ||
jsx: typeScript.JsxEmit.React, | ||
noEmit: true, | ||
skipLibCheck: true, | ||
strict: true | ||
}); | ||
|
||
const emitResult = program.emit(); | ||
const allDiagnostics = typeScript.getPreEmitDiagnostics(program).concat(emitResult.diagnostics); | ||
|
||
allDiagnostics.forEach(({ file, messageText, start }) => { | ||
if (file && start) { | ||
const { line, character } = file.getLineAndCharacterOfPosition(start); | ||
const message = typeScript.flattenDiagnosticMessageText(messageText, '\n'); | ||
|
||
throw new Error(`Failed to compile ${file.fileName} (${line + 1},${character + 1}): ${message}`); | ||
} else { | ||
throw new Error(typeScript.flattenDiagnosticMessageText(messageText, '\n')); | ||
} | ||
}); | ||
} | ||
|
||
if (filename.includes('fail')) { | ||
test(`Compile ${filename} should fail`, () => expect(() => compile(filename)).toThrow()); | ||
} else { | ||
test(`Compile ${filename} should succeed`, () => compile(filename)); | ||
} | ||
}; | ||
|
||
module.exports = { | ||
process(_, filename) { | ||
return { code: `(${run})(${JSON.stringify({ filename })})` }; | ||
} | ||
}; |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters