-
Notifications
You must be signed in to change notification settings - Fork 113
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
[Bug Report] Vuetify cli plugin breaks mocha tests #101
Comments
Happy to give any more information needed, but out of the box this is broken. Same issue as vuetifyjs/vuetify#8183 but I added a repo with the issue. |
Not sure what may be going on here, I tried adding some additional setup to the tests as described in the upgrade guide, ie, // setup.js
import Vue from 'vue'
import Vuetify from 'vuetify'
Vue.use(Vuetify) // example.spec.js
import { expect } from 'chai'
import { createLocalVue, shallowMount } from '@vue/test-utils'
import HelloWorld from '@/components/HelloWorld.vue'
import Vuetify from 'vuetify'
const localVue = createLocalVue()
describe('HelloWorld.vue', () => {
let vuetify
beforeEach(() => {
vuetify = new Vuetify()
})
it('renders props.msg when passed', () => {
const msg = 'new message'
const wrapper = shallowMount(HelloWorld, {
propsData: { msg },
localVue,
vuetify
})
expect(wrapper.text()).to.include(msg)
})
}) No luck, I get the same error. I was thinking that for some reason that a scss compiler was being invoked instead of sass, but debugging around the error into |
You can use chainWebpack: config => {
if (process.env.NODE_ENV === 'test') {
const sassRule = config.module.rule('sass')
sassRule.uses.clear()
sassRule.use('null-loader').loader('null-loader')
}
} |
In my case, after upgrading a project to Vuetify 2, the error is |
I can confirm this works for my project. Haven't gotten a chance to try it out on the minimal example in my repo yet, but I would assume it would work as well since they were demonstrating the same issue. |
This one bugged me for some times. I actually had to slightly modify the suggested solution with: chainWebpack: (config) => {
if (process.env.NODE_ENV === 'test') {
const sassRule = config.module.rule('sass')
sassRule.uses.clear()
sassRule.use('null-loader').loader('null-loader')
const scssRule = config.module.rule('scss')
scssRule.uses.clear()
scssRule.use('null-loader').loader('null-loader')
}
// Allow to mix SASS and SCSS
// https://vuetifyjs.com/en/customization/sass-variables#single-file-components
['vue-modules', 'vue', 'normal-modules', 'normal'].forEach((match) => {
config.module.rule('scss').oneOf(match).use('sass-loader')
.tap(opt => Object.assign(opt, { data: '@import "~@/styles/application.scss";' }))
})
}, I think that this documentation page should be updated to mention this. Thanks a lot @nekosaur! |
@johnleider Thanks John! Once this is released I can test this on my example project |
Testing this fix post release. Using Running
Running
I wanted to report this here to keep it attached to the original issue that we were attempting to fix but if it easier for you to open a new let me know. |
Fix issue in vuetifyjs#101
Fix issue in vuetifyjs#101 On the fresh project adding the `vue add vuetify` plugin results in a missing dependency: ``` WEBPACK Failed to compile with 9 error(s) Error in ./node_modules/vuetify/lib/components/VImg/VImg.js Module not found: 'null-loader' in '/Users/jamie/temp/vuetify-create-test' ```
Fix issue in vuetifyjs#101 On the fresh project adding the `vue add vuetify` plugin results in a missing dependency: ``` WEBPACK Failed to compile with 9 error(s) Error in ./node_modules/vuetify/lib/components/VImg/VImg.js Module not found: 'null-loader' in '/Users/jamie/temp/vuetify-create-test' ```
Fix issue in vuetifyjs#101 On the fresh project adding the `vue add vuetify` plugin results in a missing dependency: ``` WEBPACK Failed to compile with 9 error(s) Error in ./node_modules/vuetify/lib/components/VImg/VImg.js Module not found: 'null-loader' in '/Users/jamie/temp/vuetify-create-test' ```
I still have this issue with with vue ^2.6.11 and vue-cli-service ~4.4.0 and vue-cli-plugin-vuetify ~2.0.5. None of the solutions provided worked for me. I had to install null-loader first. Now, I get the sass import failures. Actually, I just realized it's not entirely the same issue since the error reads "SassError: Can't find stylesheet to import." Edit 1: So for anyone else struggling with this, I was able to resolve it like this: Use https://www.npmjs.com/package/ignore-styles and https://www.npmjs.com/package/ignore-loader. Add Then put into your vue.config.js:
Edit 2: Forget all of the above! For anyone coming across this: I still encountered some issues after configuring to ignore styles. So I did some more digging, and it turns out that my tests broke because I had in my vue.config.js:
For some reason, this causes the ExtractCssPlugin to fail in tests, presumably because the So I just did:
Now I've got everything working without any need for additional plugins or requires by simply using |
saved my life!!!!thanks!!!! |
Environment
Vuetify Version: 2.0.3
Vue Version: 2.6.10
Browsers: Chrome 75.0.3770.100
OS: Mac OS 10.14.5
Steps to reproduce
Run
yarn test:unit
Project was generated using
Vue create options
Customized to add mocha tests:
Defaults are selected for every other option
Expected Behavior
Tests will run
Actual Behavior
Tests break with sass compilation issue:
Reproduction Link
https://github.com/JamesMcMahon/vuetify-create-issues
The text was updated successfully, but these errors were encountered: