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

Can't initialize test with Jest if a component use aliplayer-react #9

Open
fky2015 opened this issue Sep 8, 2020 · 0 comments
Open

Comments

@fky2015
Copy link

fky2015 commented Sep 8, 2020

When trying to test for component use aliplayer-react, an error triggered in aliplayer-react/lib/index.js indicates that ES6 syntax import used outside the module.

  ● Test suite failed to run

    .../node_modules/aliplayer-react/lib/index.js:12
    import React, { useEffect, useRef, useMemo } from 'react';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      1 | import React, { Component } from 'react'
    > 2 | import Player from "aliplayer-react";
        | ^
      3 | import './index.less';
      4 | 
      5 | export default class AliyunPlayer extends Component {

      at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:537:17)
      at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:579:25)
      at Object.<anonymous> (src/components/AliyunPlayer/index.jsx:2:1)

I believe that Jest is a Node environment and ES6 syntax is still an experimental feature in Node.

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

1 participant