Skip to content

Commit

Permalink
chore: run compileStyle in node env
Browse files Browse the repository at this point in the history
Otherwise dart-sass thinks it is running in the browser due to jsdom
  • Loading branch information
yyx990803 committed Jul 16, 2020
1 parent 1657c05 commit 4592bc2
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions packages/compiler-sfc/__tests__/compileStyle.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/**
* @jest-environment node
*/

import {
compileStyle,
compileStyleAsync,
SFCStyleCompileOptions
} from '../src/compileStyle'
import { mockWarn } from '@vue/shared'
import path from 'path'

describe('SFC scoped CSS', () => {
mockWarn()

Expand Down Expand Up @@ -323,26 +328,15 @@ describe('SFC style preprocessors', () => {
test('scss @import', () => {
const res = compileStyle({
source: `
@import "./fixture/import.scss";
@import "./import.scss";
`,
filename: './fixture/test.scss',
filename: path.resolve(__dirname, './fixture/test.scss'),
id: '',
preprocessLang: 'scss',
preprocessOptions: {
// test with file will get error which `import.scss is not find`
importer: function(url: string, prev: string, done: string) {
if (url === './fixture/import.scss') {
return { file: path.join(__dirname, url), contents: '' }
}
}
}
preprocessLang: 'scss'
})

// test.scss will be include with 'http://localhost/test.scss'
expect(
Array.from(res.dependencies).filter(
d => !d.startsWith('http://localhost')
)
).toStrictEqual([path.join(__dirname, './fixture/import.scss')])
expect([...res.dependencies]).toStrictEqual([
path.join(__dirname, './fixture/import.scss')
])
})
})

0 comments on commit 4592bc2

Please sign in to comment.