greensock / GSAP

GSAP (GreenSock Animation Platform), a JavaScript animation library for the modern web
https://gsap.com
19.83k stars 1.72k forks source link

Can't import in Jest tests. #277

Closed Mourdraug closed 6 years ago

Mourdraug commented 6 years ago

I'm working with vue and jest unit tests. I'm checking out how it all works together and I can't run my tests. When importing TweenLite like so: import TweenLite from 'gsap/TweenLite' I get:

export const _gsScope = (typeof(window) !== "undefined") ? window : (typeof(module) !== "undefined" && module.exports && typeof(global) !== "undefined") ? global : this || {};
^^^^^^

    SyntaxError: Unexpected token export

I'm using babel-jest and other ES6 imports seem to work fine. Everything works just fine in development server as well, it only crashes in unit tests.

jackdoyle commented 6 years ago

I'm not familiar with Jest, but it sure sounds like whatever you're using doesn't recognize ES6 code like imports/exports. Perhaps it's an order-of-execution thing, like you need to transpile things to ES5 first, then run those tests(?)

Mourdraug commented 6 years ago

It might be order-of-execution kind of issue, but it's kinda weird, because import statement itself works (otherwise it'd throw Unexpected token import instead), error actually occurs further down the stack trace.