From 5b447747020a91b5bbb3c716d4297516d99e7d05 Mon Sep 17 00:00:00 2001 From: Oles Galatsan Date: Fri, 16 May 2025 10:25:02 +0300 Subject: [PATCH] Add integration test for empty TRX TestDefinitions --- __tests__/dotnet-trx.test.ts | 16 ++++++++++++++ .../dotnet-trx-empty-test-definitions.trx | 22 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 __tests__/fixtures/empty/dotnet-trx-empty-test-definitions.trx diff --git a/__tests__/dotnet-trx.test.ts b/__tests__/dotnet-trx.test.ts index d4d5dac..498abcb 100644 --- a/__tests__/dotnet-trx.test.ts +++ b/__tests__/dotnet-trx.test.ts @@ -23,6 +23,22 @@ describe('dotnet-trx tests', () => { expect(result.result).toBe('success') }) + it('produces empty test run result when TestDefinitions is empty', async () => { + const fixturePath = path.join(__dirname, 'fixtures', 'empty', 'dotnet-trx-empty-test-definitions.trx') + const filePath = normalizeFilePath(path.relative(__dirname, fixturePath)) + const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'}) + + const opts: ParseOptions = { + parseErrors: true, + trackedFiles: [] + } + + const parser = new DotnetTrxParser(opts) + const result = await parser.parse(filePath, fileContent) + expect(result.tests).toBe(0) + expect(result.result).toBe('success') + }) + it('matches report snapshot', async () => { const fixturePath = path.join(__dirname, 'fixtures', 'dotnet-trx.trx') const outputPath = path.join(__dirname, '__outputs__', 'dotnet-trx.md') diff --git a/__tests__/fixtures/empty/dotnet-trx-empty-test-definitions.trx b/__tests__/fixtures/empty/dotnet-trx-empty-test-definitions.trx new file mode 100644 index 0000000..7066144 --- /dev/null +++ b/__tests__/fixtures/empty/dotnet-trx-empty-test-definitions.trx @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + No test is available in (...). Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again. + + + +