Skip to content

Cyclic Dependency when unit testing #2804

@tjsteinhaus

Description

@tjsteinhaus

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions