Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing with jest causes Syntax error on "export" at api-ai-javascript/index.js:1 #92

Open
dtodo1paco opened this issue Aug 3, 2018 · 2 comments

Comments

@dtodo1paco
Copy link

dtodo1paco commented Aug 3, 2018

Hi!
I'm working in a React application which uses api-ai-client to integrate dialogflow features.
Everything works as espected when I manually test the application, but when I try to create some automated tests (with jest), I get the following error, just trying to render the component (which includes api-ai-client)

 FAIL  __tests__/unit/App.test.js
  ● Test suite failed to run

    /BAR/WORKSPACE/TMP/react-api-ai-poc/node_modules/api-ai-javascript/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export * from "./es6/ApiAiClient";
                                                                                             ^^^^^^
    SyntaxError: Unexpected token export

      4 | const doSendMessage = async (message, token) => {
      5 |     let ret = null;
    > 6 |     try {
      8 |         const client = new ApiAiClient({accessToken: token});

Can anybody please tell me the steps to integrate this api (and to mock it if possible) ?

// .babelrc

{
  "presets": [
    "env",
    "react",
    "latest",
    "stage-2"
  ],
  "plugins": ["transform-remove-strict-mode"]

}

Also tried in jest.config

transform: {
        "^.+\\.jsx?$": "babel-jest"
 },

Regards,

@dtodo1paco dtodo1paco changed the title Testing with jest Testing with jest causes Syntax error on "export" at api-ai-javascript/index.js:1 Aug 3, 2018
@lnm8910
Copy link

lnm8910 commented Nov 18, 2019

Hey, did you get an solution to this issue?

@dtodo1paco
Copy link
Author

Yes, you can take a look here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants