Skip to content

Commit

Permalink
test: simplify old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Apr 27, 2024
1 parent 3f9d54f commit 7d99cd2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 346 deletions.
6 changes: 5 additions & 1 deletion packages/vitest/src/node/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ interface PrintErrorResult {
}

// use Logger with custom Console to capture entire error printing
export async function captuerPrintError(error: unknown, ctx: Vitest, project: WorkspaceProject) {
export async function captuerPrintError(
error: unknown,
ctx: Vitest,
project: WorkspaceProject,
) {
let output = ''
const writable = new Writable({
write(chunk, _encoding, callback) {
Expand Down
63 changes: 0 additions & 63 deletions test/reporters/src/data-for-junit.ts

This file was deleted.

207 changes: 6 additions & 201 deletions test/reporters/tests/__snapshots__/reporters.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,14 @@

exports[`JUnit reporter (no outputFile entry) 1`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="9" failures="1" errors="0" time="0">
<testsuite name="test/core/test/basic.test.ts" timestamp="2022-01-19T10:10:01.759Z" hostname="hostname" tests="9" failures="1" errors="0" skipped="2" time="0.145992842">
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; inner suite &gt; Math.sqrt()" time="0.001442286">
<failure message="expected 2.23606797749979 to equal 2" type="AssertionError">
AssertionError: expected 2.23606797749979 to equal 2
❯ test/core/test/basic.test.ts:8:32
</failure>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; JSON" time="0.001023711">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; async with timeout" time="0">
<skipped/>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; timeout" time="0.1005059841">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success " time="0.020184875">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success " time="0.0003324542">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success done(false)" time="0.019738606">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success done(false)" time="0.0001923509">
<system-err>
[33merror[39m
</system-err>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; todo test" time="0">
<skipped/>
</testcase>
</testsuite>
<testsuites name="vitest tests" tests="0" failures="0" errors="0" time="0">
</testsuites>
"
`;

exports[`JUnit reporter 1`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="9" failures="1" errors="0" time="0">
<testsuite name="test/core/test/basic.test.ts" timestamp="2022-01-19T10:10:01.759Z" hostname="hostname" tests="9" failures="1" errors="0" skipped="2" time="0.145992842">
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; inner suite &gt; Math.sqrt()" time="0.001442286">
<failure message="expected 2.23606797749979 to equal 2" type="AssertionError">
AssertionError: expected 2.23606797749979 to equal 2
❯ test/core/test/basic.test.ts:8:32
</failure>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; JSON" time="0.001023711">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; async with timeout" time="0">
<skipped/>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; timeout" time="0.1005059841">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success " time="0.020184875">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success " time="0.0003324542">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success done(false)" time="0.019738606">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success done(false)" time="0.0001923509">
<system-err>
[33merror[39m
</system-err>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; todo test" time="0">
<skipped/>
</testcase>
</testsuite>
<testsuites name="vitest tests" tests="0" failures="0" errors="0" time="0">
</testsuites>
"
`;
Expand All @@ -79,36 +21,7 @@ exports[`JUnit reporter with outputFile 1`] = `
exports[`JUnit reporter with outputFile 2`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="9" failures="1" errors="0" time="0">
<testsuite name="test/core/test/basic.test.ts" timestamp="2022-01-19T10:10:01.759Z" hostname="hostname" tests="9" failures="1" errors="0" skipped="2" time="0.145992842">
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; inner suite &gt; Math.sqrt()" time="0.001442286">
<failure message="expected 2.23606797749979 to equal 2" type="AssertionError">
AssertionError: expected 2.23606797749979 to equal 2
❯ test/core/test/basic.test.ts:8:32
</failure>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; JSON" time="0.001023711">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; async with timeout" time="0">
<skipped/>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; timeout" time="0.1005059841">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success " time="0.020184875">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success " time="0.0003324542">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success done(false)" time="0.019738606">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success done(false)" time="0.0001923509">
<system-err>
[33merror[39m
</system-err>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; todo test" time="0">
<skipped/>
</testcase>
</testsuite>
<testsuites name="vitest tests" tests="0" failures="0" errors="0" time="0">
</testsuites>
"
`;
Expand All @@ -120,36 +33,7 @@ exports[`JUnit reporter with outputFile in non-existing directory 1`] = `
exports[`JUnit reporter with outputFile in non-existing directory 2`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="9" failures="1" errors="0" time="0">
<testsuite name="test/core/test/basic.test.ts" timestamp="2022-01-19T10:10:01.759Z" hostname="hostname" tests="9" failures="1" errors="0" skipped="2" time="0.145992842">
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; inner suite &gt; Math.sqrt()" time="0.001442286">
<failure message="expected 2.23606797749979 to equal 2" type="AssertionError">
AssertionError: expected 2.23606797749979 to equal 2
❯ test/core/test/basic.test.ts:8:32
</failure>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; JSON" time="0.001023711">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; async with timeout" time="0">
<skipped/>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; timeout" time="0.1005059841">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success " time="0.020184875">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success " time="0.0003324542">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success done(false)" time="0.019738606">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success done(false)" time="0.0001923509">
<system-err>
[33merror[39m
</system-err>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; todo test" time="0">
<skipped/>
</testcase>
</testsuite>
<testsuites name="vitest tests" tests="0" failures="0" errors="0" time="0">
</testsuites>
"
`;
Expand All @@ -161,36 +45,7 @@ exports[`JUnit reporter with outputFile object 1`] = `
exports[`JUnit reporter with outputFile object 2`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="9" failures="1" errors="0" time="0">
<testsuite name="test/core/test/basic.test.ts" timestamp="2022-01-19T10:10:01.759Z" hostname="hostname" tests="9" failures="1" errors="0" skipped="2" time="0.145992842">
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; inner suite &gt; Math.sqrt()" time="0.001442286">
<failure message="expected 2.23606797749979 to equal 2" type="AssertionError">
AssertionError: expected 2.23606797749979 to equal 2
❯ test/core/test/basic.test.ts:8:32
</failure>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; JSON" time="0.001023711">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; async with timeout" time="0">
<skipped/>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; timeout" time="0.1005059841">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success " time="0.020184875">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success " time="0.0003324542">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success done(false)" time="0.019738606">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success done(false)" time="0.0001923509">
<system-err>
[33merror[39m
</system-err>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; todo test" time="0">
<skipped/>
</testcase>
</testsuite>
<testsuites name="vitest tests" tests="0" failures="0" errors="0" time="0">
</testsuites>
"
`;
Expand All @@ -202,57 +57,7 @@ exports[`JUnit reporter with outputFile object in non-existing directory 1`] = `
exports[`JUnit reporter with outputFile object in non-existing directory 2`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="9" failures="1" errors="0" time="0">
<testsuite name="test/core/test/basic.test.ts" timestamp="2022-01-19T10:10:01.759Z" hostname="hostname" tests="9" failures="1" errors="0" skipped="2" time="0.145992842">
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; inner suite &gt; Math.sqrt()" time="0.001442286">
<failure message="expected 2.23606797749979 to equal 2" type="AssertionError">
AssertionError: expected 2.23606797749979 to equal 2
❯ test/core/test/basic.test.ts:8:32
</failure>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; JSON" time="0.001023711">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; async with timeout" time="0">
<skipped/>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; timeout" time="0.1005059841">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success " time="0.020184875">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success " time="0.0003324542">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback setup success done(false)" time="0.019738606">
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; callback test success done(false)" time="0.0001923509">
<system-err>
[33merror[39m
</system-err>
</testcase>
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; todo test" time="0">
<skipped/>
</testcase>
</testsuite>
</testsuites>
"
`;
exports[`JUnit reporter with outputFile with XML in error message 1`] = `
"JUNIT report written to <process-cwd>/report_escape_msg_xml.xml
"
`;
exports[`JUnit reporter with outputFile with XML in error message 2`] = `
"<?xml version="1.0" encoding="UTF-8" ?>
<testsuites name="vitest tests" tests="1" failures="1" errors="0" time="0">
<testsuite name="test/core/test/basic.test.ts" timestamp="2022-01-19T10:10:01.759Z" hostname="hostname" tests="1" failures="1" errors="0" skipped="0" time="0.145992842">
<testcase classname="test/core/test/basic.test.ts" name="suite &gt; test with xml in error" time="0.0021231231">
<failure message="error message that has XML in it &lt;tag&gt;" type="AssertionError">
AssertionError: error message that has XML in it &lt;tag&gt;
❯ test/core/test/basic.test.ts:8:32
❯ test/core/test/&lt;bracket-name&gt;.ts:3:11
</failure>
</testcase>
</testsuite>
<testsuites name="vitest tests" tests="0" failures="0" errors="0" time="0">
</testsuites>
"
`;
Expand Down
Loading

0 comments on commit 7d99cd2

Please sign in to comment.