You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please explain the issue and what was your expectation
I created this app using the create react app command with the TypeScript command. The test files should automatically work, but they didn't. This issue reminds me to add tests to the app once this issue is fixed.
Running the test produces the following output in the console.
Test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
SyntaxError: F:\Code\tweet-to-image\src\App.test.tsx: Support for the experimental syntax 'jsx' isn't currently enabled (4:12):
2 |
3 | test('fefe', ()=> {
> 4 | render(<div>fefe</div>);
| ^
5 | expect(1).toBe(1);
6 | });
7 |
Add @babel/preset-react (https://github.com/babel/babel/tree/main/packages/babel-preset-react) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is, add @babel/plugin-syntax-jsx (https://github.com/babel/babel/tree/main/packages/babel-plugin-syntax-jsx) to the 'plugins' section to enable parsing.
at instantiate (node_modules/@babel/parser/src/parse-error/credentials.js:61:22)
at toParseError (node_modules/@babel/parser/src/parse-error.js:58:12)
at Parser.raise (node_modules/@babel/parser/src/tokenizer/index.js:1736:19)
at Parser.expectOnePlugin (node_modules/@babel/parser/src/tokenizer/index.js:1800:18)
at Parser.parseExprAtom (node_modules/@babel/parser/src/parser/expression.js:1239:16)
at Parser.parseExprSubscripts (node_modules/@babel/parser/src/parser/expression.js:684:23)
at Parser.parseUpdate (node_modules/@babel/parser/src/parser/expression.js:663:21)
at Parser.parseMaybeUnary (node_modules/@babel/parser/src/parser/expression.js:632:23)
at Parser.parseMaybeUnaryOrPrivate (node_modules/@babel/parser/src/parser/expression.js:384:14)
at Parser.parseExprOps (node_modules/@babel/parser/src/parser/expression.js:394:23)
Browser information
N/A
The text was updated successfully, but these errors were encountered:
Please explain the issue and what was your expectation
I created this app using the create react app command with the TypeScript command. The test files should automatically work, but they didn't. This issue reminds me to add tests to the app once this issue is fixed.
The main issue is being tracked in the library here - facebook/create-react-app#11700
Please elaborate the steps to reproduce the issue
Add a sample test file with the contents below.
Running the test produces the following output in the console.
Browser information
N/A
The text was updated successfully, but these errors were encountered: