Skip to content

Commit d9d993f

Browse files
committed
test: update e2e log
1 parent 2e8f90c commit d9d993f

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

__tests__/e2e.spec.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ if (process.platform === 'linux') {
6060

6161
describe('[create-electron-vite] e2e tests', async () => {
6262
test('startup', async () => {
63+
console.log('[e2e] npm-install.log:\n', readFileSync('npm-install.log'))
64+
console.log('[e2e] vite-build.log:\n', readFileSync('vite-build.log'))
65+
6366
const title = await page.title()
6467
expect(title).eq('Vite + Vue + TS')
6568
})
@@ -98,15 +101,14 @@ async function createProject() {
98101

99102
// For local testing
100103
function enableElectronMirror() {
101-
const npmrc = path.join(generatePath, '.npmrc')
102-
let npmrcContent = fs.readFileSync(npmrc, 'utf8')
104+
let npmrcContent = readFileSync('.npmrc')
103105

104106
npmrcContent = npmrcContent
105107
.split('\n')
106-
.map((line) => line.includes('electron_mirror') ? line.replace('#', '').trim() : line)
108+
.map((line) => line.includes('electron_mirror') ? line.replace('#', '').trimStart() : line)
107109
.join('\n')
108110

109-
fs.writeFileSync(npmrc, npmrcContent)
111+
writeFileSync('.npmrc', npmrcContent)
110112
}
111113

112114
function execSync(command: string) {
@@ -117,6 +119,10 @@ function writeFileSync(file: string, content: string) {
117119
return fs.writeFileSync(path.join(generatePath, file), content)
118120
}
119121

122+
function readFileSync(file: string) {
123+
return fs.readFileSync(path.join(generatePath, file), 'utf8')
124+
}
125+
120126
function intervalTask<R>(fn: (args: { stop: () => void }) => R | Promise<R>, options?: {
121127
delay?: number
122128
timeout?: number

vitest.config.ts

-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
import fs from 'node:fs'
2-
import path from 'node:path'
31
import { defineConfig } from 'vitest/config'
42

5-
const logs = path.join(__dirname, 'logs')
6-
const stdout = 'test-console.stdout.log'
7-
const stderr = 'test-console.stderr.log'
8-
9-
fs.existsSync(logs) || fs.mkdirSync(logs, { recursive: true })
10-
for (const log of [stdout, stderr]) {
11-
// Clear cache logs
12-
fs.rmSync(path.join(logs, log), { recursive: true, force: true })
13-
}
14-
153
export default defineConfig({
164
test: {
175
root: __dirname,
186
include: ['__tests__/**/*.{test,spec}.?(c|m)[jt]s?(x)'],
19-
onConsoleLog(log, type) {
20-
fs.appendFileSync(path.join(logs, `test-console.${type}.log`), log)
21-
},
227
},
238
})

0 commit comments

Comments
 (0)