| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,7 +92,12 @@ export class JUnitReporter implements Reporter { | |||
| 92 | 92 | const fileFd = await fs.open(this.reportFile, 'w+') | |
| 93 | 93 | this.fileFd = fileFd | |
| 94 | 94 | ||
| 95 | - this.baseLog = async (text: string) => await fs.writeFile(fileFd, `${text}\n`) | ||
| 95 | + this.baseLog = async (text: string) => { | ||
| 96 | + if (!this.fileFd) | ||
| 97 | + this.fileFd = await fs.open(this.reportFile!, 'w+') | ||
| 98 | + | ||
| 99 | + await fs.writeFile(this.fileFd, `${text}\n`) | ||
| 100 | + } | ||
| 96 | 101 | } | |
| 97 | 102 | else { | |
| 98 | 103 | this.baseLog = async (text: string) => this.ctx.logger.log(text) | |
@@ -248,5 +253,6 @@ export class JUnitReporter implements Reporter { | |||
| 248 | 253 | this.ctx.logger.log(`JUNIT report written to ${this.reportFile}`) | |
| 249 | 254 | ||
| 250 | 255 | await this.fileFd?.close() | |
| 256 | + this.fileFd = undefined | ||
| 251 | 257 | } | |
| 252 | 258 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -115,7 +115,7 @@ export async function runVitestCli(_options?: Options | string, ...args: string[ | |||
| 115 | 115 | return resolve() | |
| 116 | 116 | ||
| 117 | 117 | const timeout = setTimeout(() => { | |
| 118 | - reject(new Error(`Timeout when waiting for output "${expected}".\nReceived:\n${this.stdout}`)) | ||
| 118 | + reject(new Error(`Timeout when waiting for output "${expected}".\nReceived:\n${this.stdout}. \nStderr:\n${this.stderr}`)) | ||
| 119 | 119 | }, process.env.CI ? 20_000 : 4_000) | |
| 120 | 120 | ||
| 121 | 121 | const listener = () => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + fixtures/test-results | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | - import { readFileSync, rmSync, writeFileSync } from 'node:fs' | ||
| 2 | - import { afterEach, describe, test } from 'vitest' | ||
| 1 | + import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs' | ||
| 2 | + import { afterEach, describe, expect, test } from 'vitest' | ||
| 3 | 3 | ||
| 4 | 4 | import { runVitestCli } from '../../test-utils' | |
| 5 | 5 | ||
@@ -88,6 +88,35 @@ test("dynamic test case", () => { | |||
| 88 | 88 | await vitest.waitForStdout('1 passed') | |
| 89 | 89 | }) | |
| 90 | 90 | ||
| 91 | + test('editing source file generates new test report to file system', async () => { | ||
| 92 | + const report = 'fixtures/test-results/junit.xml' | ||
| 93 | + if (existsSync(report)) | ||
| 94 | + rmSync(report) | ||
| 95 | + | ||
| 96 | + // Test report should not be present before test run | ||
| 97 | + expect(existsSync(report)).toBe(false) | ||
| 98 | + | ||
| 99 | + const vitest = await runVitestCli( | ||
| 100 | + ...cliArgs, | ||
| 101 | + '--reporter', 'verbose', | ||
| 102 | + '--reporter', 'junit', | ||
| 103 | + '--output-file', 'test-results/junit.xml', | ||
| 104 | + ) | ||
| 105 | + | ||
| 106 | + // Test report should be generated on initial test run | ||
| 107 | + expect(existsSync(report)).toBe(true) | ||
| 108 | + | ||
| 109 | + // Test report should be re-generated on second test run | ||
| 110 | + rmSync(report) | ||
| 111 | + expect(existsSync(report)).toBe(false) | ||
| 112 | + | ||
| 113 | + writeFileSync(sourceFile, editFile(sourceFileContent), 'utf8') | ||
| 114 | + | ||
| 115 | + await vitest.waitForStdout('JUNIT report written') | ||
| 116 | + await vitest.waitForStdout(report) | ||
| 117 | + expect(existsSync(report)).toBe(true) | ||
| 118 | + }) | ||
| 119 | + | ||
| 91 | 120 | describe('browser', () => { | |
| 92 | 121 | test.runIf((process.platform !== 'win32'))('editing source file triggers re-run', async () => { | |
| 93 | 122 | const vitest = await runVitestCli(...cliArgs, '--browser.enabled', '--browser.headless', '--browser.name=chrome') | |
| Back | FazBrowse Home | New Git URL |
0 commit comments