Tests won't compile because library is published as ES6
See original GitHub issueI am trying to run simple test case in TypeScript project but I am getting
> mocha
/myApp/node_modules/react-native-testing-library/src/index.js:2
import render from './render';
^^^^^^
SyntaxError: Unexpected token import
This means that you guys are publishing the project code in ES6 even though node_modules should be released as ES5.
Could you compile the library code to ES5 and republish that 😃
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:13 (9 by maintainers)
Top Results From Across the Web
TypeScript ES6 import module "File is not a module error"
When I am trying to compile the main.ts file I get this error: Error TS2306: File 'test.ts' is not a module. How can...
Read more >Testing in ES6 with Mocha and Babel 6 - James K Nelson
Naturally, your tests import the lib code which you're actually publishing, not the original src files.
Read more >Adding ES6 Support to Tests using Mocha and Babel
[00:48] To do this, we're going to leverage the compilers flag. For JS files, we want to use the babel-register compiler. This is...
Read more >10 minute JavaScript: Library development in ES6 with Babel ...
We'll be setting up a project that allows us to write ES6, and distribute it in ES5 (with Babel) and to test it...
Read more >Build a JavaScript Util Library for NPM with ES6 Modules and ...
I've chosen to use TypeScript for this project, but you don't have to. It's perfectly fine if you want to use regular ES6...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Feel free to fix it, this is an open source project and I didn’t say no to this kind of improvement 😃.
We mainly target React Native, where projects are released as source. Before you feed this lib to your TS compiler, you’ll need to run it through Babel with
metro-react-native-babel-preset
.I think we could compile it to ES5 though, I’m happy to review and accept the PR with that change 😃