Skip to content

Commit c26db3b

Browse files
hmskeddyerburgh
authored andcommitted
fix: avoid parsing LESS, and PostCSS (#58)
1 parent ca9db33 commit c26db3b

File tree

5 files changed

+58
-2
lines changed

5 files changed

+58
-2
lines changed

lib/process.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ module.exports = function (src, filePath) {
103103
if (Array.isArray(parts.styles) && parts.styles.length > 0) {
104104
const styleStr = parts.styles.map(ast => {
105105
if (!module) return
106-
if (/^scss|sass/.test(ast.lang)) {
107-
logger.warn('scss and sass are not currently compiled by vue-jest')
106+
if (/^scss|sass|less|pcss|postcss/.test(ast.lang)) {
107+
logger.warn('Sass/SCSS, Less and PostCSS are not currently compiled by vue-jest')
108108
return false
109109
}
110110

test/less.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { shallow } from 'vue-test-utils'
2+
import Less from './resources/Less.vue'
3+
4+
describe('processes .vue file with Less style', () => {
5+
it('does not error on less', () => {
6+
const wrapper = shallow(Less)
7+
expect(wrapper.classes()).toContain('testLess')
8+
})
9+
})

test/postcss.spec.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { shallow } from 'vue-test-utils'
2+
import PostCss from './resources/PostCss.vue'
3+
4+
describe('processes .vue file with PostCSS style', () => {
5+
it('does not error on pcss/postcss', () => {
6+
const wrapper = shallow(PostCss)
7+
expect(wrapper.classes()).toContain('testPcss')
8+
})
9+
})

test/resources/Less.vue

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template>
2+
<div class="testLess"></div>
3+
</template>
4+
5+
<style lang="less">
6+
@import "./styles/transitions";
7+
8+
.testLess {
9+
background-color: red;
10+
}
11+
</style>
12+
13+
<style lang="less">
14+
@primary-color: #333;
15+
</style>

test/resources/PostCss.vue

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<template>
2+
<div class="testPcss"></div>
3+
</template>
4+
5+
<style lang="postcss">
6+
@import "./styles/transitions";
7+
8+
.testPcss {
9+
background-color: purple;
10+
}
11+
</style>
12+
13+
<style lang="pcss">
14+
/* This syntax is for postcss-custom-properties */
15+
--primary-color: green;
16+
17+
/* This syntax is for postcss-nesting, but invalid as Pure CSS */
18+
body {
19+
@media screen {
20+
background-color: grey;
21+
}
22+
}
23+
</style>

0 commit comments

Comments
 (0)