question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tests won't compile because library is published as ES6

See original GitHub issue

I 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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
thymikeecommented, Oct 29, 2018

Feel free to fix it, this is an open source project and I didn’t say no to this kind of improvement 😃.

1reaction
thymikeecommented, Oct 29, 2018

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found