Vue-cli: Cyclic Dependency when unit testing

Created on 25 Oct 2018  路  9Comments  路  Source: vuejs/vue-cli

Version

3.0.4

Node and OS info

npm

Steps to reproduce

Sorry, can't link to reproduction as this is a work application.

However, when we import any of our Vue Components into our unit test we get a Cyclic dependency error. I have checked all our files manually and used a couple tools like Madge and each of them show that I don't have any Circular Dependencies. This appears to be happening from the toposort module.

Error below.

Error: Cyclic dependency
    at visit (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/toposort/index.js:35:13)
    at visit (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/toposort/index.js:53:9)    at visit (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/toposort/index.js:53:9)    at Function.toposort [as array] (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/toposort/index.js:22:22)    at sortChunks (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/mocha-webpack/lib/webpack/util/sortChunks.js:35:41)
    at getBuildStats (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/mocha-webpack/lib/webpack/util/getBuildStats.js:29:47)    at TestRunner.prepareMocha (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/mocha-webpack/lib/runner/TestRunner.js:135:52)    at /mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/mocha-webpack/lib/runner/TestRunner.js:188:38
    at /mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/@vue/cli-plugin-unit-mocha/node_modules/mocha-webpack/lib/webpack/compiler/registerReadyCallback.js:26:7
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:45:1)    at AsyncSeriesHook.lazyCompileHook (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/tapable/lib/Hook.js:154:20)    at emitRecords.err (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/webpack/lib/Compiler.js:251:22)
    at Compiler.emitRecords (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/webpack/lib/Compiler.js:366:39)
    at emitAssets.err (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/webpack/lib/Compiler.js:245:10)
    at hooks.afterEmit.callAsync.err (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/webpack/lib/Compiler.js:352:14)    at _err0 (eval at create (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:16:1)
    at callback (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/copy-webpack-plugin/dist/index.js:126:17)
    at afterEmit (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/copy-webpack-plugin/dist/index.js:220:13)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:12:1)    at AsyncSeriesHook.lazyCompileHook (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/tapable/lib/Hook.js:154:20)
    at asyncLib.forEach.err (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/webpack/lib/Compiler.js:349:27)
    at /mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/neo-async/async.js:2825:7
    at done (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/neo-async/async.js:2861:11)
    at /mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/neo-async/async.js:2813:7
    at MemoryFileSystem.writeFile (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/memory-fs/lib/MemoryFileSystem.js:328:9)
    at writeOut (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/webpack/lib/Compiler.js:333:29)
    at Immediate._onImmediate (/mnt/c/Users/Tyler/Documents/Work/myaccount-vue/node_modules/memory-fs/lib/MemoryFileSystem.js:288:4)
    at runCallback (timers.js:794:20)
    at tryOnImmediate (timers.js:752:5)
    at processImmediate [as _immediateCallback] (timers.js:729:5)
 ERROR  mocha-webpack exited with code 1.

What is expected?

Successfully run mocha to check our unit testing

What is actually happening?

Giving an error


I've tried to update Toposort and mocha but neither worked.

bug unit-mocha upstream

Most helpful comment

before the bug fixed, how can we solve the problem? Thanks for reading @sodatea

All 9 comments

I guess the error is raised from this file: https://github.com/zinserjan/mocha-webpack/blob/master/src/webpack/util/sortChunks.js

In the normal bundle we've overridden this function https://github.com/vuejs/vue-cli/blob/667fc3dd1937d887e43f50201de66537be6328db/packages/%40vue/cli-service/lib/config/app.js#L51-L74 but didn't expect that there's a copy in mocha-webpack

Thank you for responding. I hope this can get fixed shortly.

Thanks again!
Tyler

Has there been any progress on this issue?

I also am seeing this issue. Any update?

before the bug fixed, how can we solve the problem? Thanks for reading @sodatea

Hello. Any update?

No progress? Any suggested workarounds?

same issue here

Updating to vue cli 4.2.3 solved the issue for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Benzenes picture Benzenes  路  3Comments

OmgImAlexis picture OmgImAlexis  路  3Comments

BusyHe picture BusyHe  路  3Comments

joshuajohnson814 picture joshuajohnson814  路  3Comments

b-zee picture b-zee  路  3Comments