-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
includePaths not working with dart-sass and @vue/cli-plugin-unit-mocha #6427
Comments
After a period of debugging, I found that dart-sass assume that we are running in a browser(Since we set sass.dart.js var dartNodePreambleSelf = typeof global !== "undefined" ? global : window;
// if we're running in a browser, Dart supports most of this out of box
// make sure we only run these in Node.js environment
var dartNodeIsActuallyNode = !dartNodePreambleSelf.window when running when running The difference in what happeneddart-sass tries to load a stylesheet (not serious)
working directory determined by when loading a stylesheet from To verify, I modified the code in - require('jsdom-global')(undefined, { pretendToBeVisual: true, url: 'http://localhost' })
+ const url = require('url')
+ require('jsdom-global')(undefined, { pretendToBeVisual: true, url: url.pathToFileURL(process.cwd()).href + "/" })
// https://github.com/vuejs/vue-test-utils/issues/936
window.Date = Date
// https://github.com/vuejs/vue-next/pull/2943
global.ShadowRoot = window.ShadowRoot
+global.SVGElement = window.SVGElement I'm not sure if it's the solution of this issue, and whether this solution will cause other problems. (may affect vue-router) but according to the code used by dart-sass, I think a better but ugly hackish workaround maybe like this require('jsdom-global')(undefined, { pretendToBeVisual: true, url: 'http://localhost' })
process.versions.electron = ''
|
Thanks for your answer and investigation @fangbinwei ! I edited the issue to reflect more precisely on what's happening for google users 👍 |
Also I can confirm that with your changes, my "mock" project and my real project are both working and passing their tests. 👍 |
Version
4.5.12
Reproduction link
https://github.com/lambertkevin/vue-cli-mocha-bug
Environment info
Steps to reproduce
1- Add an
includePaths
in thesassOptions
of avue.config.js
file.2- In your style,
@import
/@use
a file that should be accessible through theincludePaths
option in any file that will be tested with mocha (i.e. HelloWorld.vue in the vue boilerplate).3-
npm run test:unit
What is expected?
It should be able to
@import
/@use
any sass/scss file from theincludePaths
options.What is actually happening?
Tests won't pass because of importing issues.
The text was updated successfully, but these errors were encountered: