vue-echarts-v3 icon indicating copy to clipboard operation
vue-echarts-v3 copied to clipboard

Not be able to test the components used vue-echarts-v3 full.js

Open fengo4142 opened this issue 4 years ago • 2 comments

With jest, I would like to test my components which have child components of vue-echarts-v3 imported by full.js. I think it is due to using the native source code in an unaltered/unbundled state instead of using the bundled version.

  ● Test suite failed to run

    /Volumes/Work/xcuseme/mapp/node_modules/vue-echarts-v3/src/full.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import * as ECharts from 'echarts';
                                                                                             ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      43 | 
      44 | <script>
    > 45 | import IEcharts from "vue-echarts-v3/src/full.js";
         | ^
      46 | import StatMixin from "../../mixins/StatMixin";
      47 | 
      48 | export default {

      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 src/components/Account/Stats.vue:45:1

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        4.243s

is there any way I can fix it not altering my source code.

fengo4142 avatar Jul 21 '20 21:07 fengo4142

Please let me know if you could get around this somehow @fengo4142

viniciusdeliz avatar Dec 23 '21 02:12 viniciusdeliz

The error in my environment happens with lite.js while testing.

` Details:

/home/vin/code/node_modules/vue-echarts-v3/src/lite.js:1
import * as ECharts from 'echarts/lib/echarts';
       ^

SyntaxError: Unexpected token *

  16 |
  17 | <script>
> 18 | import echarts from 'vue-echarts-v3/src/lite.js';
     | ^
  19 | import 'echarts/lib/chart/bar';
  20 | import 'echarts/lib/chart/line';
  21 | import 'echarts/lib/component/title/';

  at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)`

viniciusdeliz avatar Dec 23 '21 02:12 viniciusdeliz