0

I want to use the Jest testing framework to test vanilla Javascript (not React). I'm getting an error SyntaxError: Unexpected token import.

My file is called functionName.js and my test file is called functionName.test.js. Both are in the same folder. I used export const functionName and import functionName from './functionName.js' to export/import the function I'm testing. It works fine when I use module.exports = functionName and const functionName = require('./functionName.js') but that's ES5 notation and I want to write it in ES6.

I'm new to using Jest, so any help would be much appreciated, thanks.

fafafariba
  • 335
  • 1
  • 2
  • 12
  • This is a deep rabbit hole. Basically the code still needs to be transpiled to a supported format. – E. Sundin Jul 03 '17 at 15:24
  • I have had this issue before. Please see https://stackoverflow.com/questions/44476725/unexpected-token-import-error-in-while-running-jest-tests – demouser123 Jul 03 '17 at 15:42

0 Answers0