Skip to content

Commit e658563

Browse files
committed
test: fix vue.config.js tests
1 parent bf9a304 commit e658563

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/@vue/cli-service/__tests__/Service.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
jest.mock('fs')
2-
jest.mock('mock-config', () => ({ lintOnSave: false }), { virtual: true })
2+
jest.mock('/vue.config.js', () => ({ lintOnSave: false }), { virtual: true })
33
jest.mock('vue-cli-plugin-foo', () => () => {}, { virtual: true })
44

55
const fs = require('fs')
@@ -53,16 +53,16 @@ test('load project options from package.json', () => {
5353
})
5454

5555
test('load project options from vue.config.js', () => {
56-
process.env.VUE_CLI_SERVICE_CONFIG_PATH = 'mock-config'
56+
fs.writeFileSync('/vue.config.js', `module.exports = { lintOnSave: false }`)
5757
mockPkg({
5858
vue: {
5959
lintOnSave: true
6060
}
6161
})
6262
const service = createMockService()
63+
fs.unlinkSync('/vue.config.js')
6364
// vue.config.js has higher priority
6465
expect(service.projectOptions.lintOnSave).toBe(false)
65-
delete process.env.VUE_CLI_SERVICE_CONFIG_PATH
6666
})
6767

6868
test('api: setMode', () => {

packages/@vue/cli-service/lib/Service.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,11 @@ module.exports = class Service {
159159
loadProjectOptions (inlineOptions) {
160160
// vue.config.js
161161
let fileConfig, pkgConfig, resolved, resovledFrom
162-
const configPath = (
163-
process.env.VUE_CLI_SERVICE_CONFIG_PATH ||
164-
path.resolve(this.context, 'vue.config.js')
165-
)
162+
const configPath = path.resolve(this.context, 'vue.config.js')
166163
if (fs.existsSync(configPath)) {
167164
try {
168165
fileConfig = require(configPath)
166+
console.log(fileConfig)
169167
if (!fileConfig || typeof fileConfig !== 'object') {
170168
error(
171169
`Error loading ${chalk.bold('vue.config.js')}: should export an object.`

0 commit comments

Comments
 (0)