Skip to content

Avoid parsing LESS, PostCSS too #58

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

Merged
merged 1 commit into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ module.exports = function (src, filePath) {
if (Array.isArray(parts.styles) && parts.styles.length > 0) {
const styleStr = parts.styles.map(ast => {
if (!module) return
if (/^scss|sass/.test(ast.lang)) {
logger.warn('scss and sass are not currently compiled by vue-jest')
if (/^scss|sass|less|pcss|postcss/.test(ast.lang)) {
logger.warn('Sass/SCSS, Less and PostCSS are not currently compiled by vue-jest')
return false
}

Expand Down
9 changes: 9 additions & 0 deletions test/less.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { shallow } from 'vue-test-utils'
import Less from './resources/Less.vue'

describe('processes .vue file with Less style', () => {
it('does not error on less', () => {
const wrapper = shallow(Less)
expect(wrapper.classes()).toContain('testLess')
})
})
9 changes: 9 additions & 0 deletions test/postcss.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { shallow } from 'vue-test-utils'
import PostCss from './resources/PostCss.vue'

describe('processes .vue file with PostCSS style', () => {
it('does not error on pcss/postcss', () => {
const wrapper = shallow(PostCss)
expect(wrapper.classes()).toContain('testPcss')
})
})
15 changes: 15 additions & 0 deletions test/resources/Less.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<template>
<div class="testLess"></div>
</template>

<style lang="less">
@import "./styles/transitions";
.testLess {
background-color: red;
}
</style>

<style lang="less">
@primary-color: #333;
</style>
23 changes: 23 additions & 0 deletions test/resources/PostCss.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<template>
<div class="testPcss"></div>
</template>

<style lang="postcss">
@import "./styles/transitions";
.testPcss {
background-color: purple;
}
</style>

<style lang="pcss">
/* This syntax is for postcss-custom-properties */
--primary-color: green;
/* This syntax is for postcss-nesting, but invalid as Pure CSS */
body {
@media screen {
background-color: grey;
}
}
</style>