Skip to content

Commit 509ba7e

Browse files
committed
test: isolate test-projects from each-other
1 parent 0586b06 commit 509ba7e

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

src/Playwright.TestingHarnessTest/Playwright.TestingHarnessTest.csproj

+16-12
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@
88
</PropertyGroup>
99
<Import Project="../Common/SignAssembly.props" />
1010

11-
<ItemGroup>
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
13-
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
14-
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
15-
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
16-
<PackageReference Include="xunit" Version="2.9.2" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
18-
</ItemGroup>
19-
2011
<ItemGroup>
2112
<ProjectReference Include="..\Playwright\Playwright.csproj" />
22-
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" />
23-
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" />
24-
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" />
13+
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
15+
16+
<!-- MSTest -->
17+
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" Condition="'$(TEST_MODE)' == 'mstest'" />
18+
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />
19+
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />
20+
21+
<!-- NUnit -->
22+
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" Condition="'$(TEST_MODE)' == 'nunit'" />
23+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" Condition="'$(TEST_MODE)' == 'nunit'" />
24+
25+
<!-- xUnit -->
26+
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" Condition="'$(TEST_MODE)' == 'xunit'" />
27+
<PackageReference Include="xunit" Version="2.9.2" Condition="'$(TEST_MODE)' == 'xunit'" />
28+
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" Condition="'$(TEST_MODE)' == 'xunit'" />
2529
</ItemGroup>
2630
</Project>

src/Playwright.TestingHarnessTest/tests/baseTest.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ type RunResult = {
1616
}
1717

1818
export const test = base.extend<{
19+
testMode: 'nunit' | 'mstest' | 'xunit';
1920
runTest: (files: Record<string, string>, command: string, env?: NodeJS.ProcessEnv) => Promise<RunResult>;
2021
}>({
21-
runTest: async ({ }, use, testInfo) => {
22+
testMode: null,
23+
runTest: async ({ testMode }, use, testInfo) => {
2224
const testResults: RunResult[] = [];
2325
await use(async (files, command, env) => {
2426
const testDir = testInfo.outputPath();
@@ -34,7 +36,8 @@ export const test = base.extend<{
3436
env: {
3537
...process.env,
3638
...env,
37-
NODE_OPTIONS: undefined
39+
NODE_OPTIONS: undefined,
40+
TEST_MODE: testMode,
3841
},
3942
stdio: 'pipe',
4043
});

src/Playwright.TestingHarnessTest/tests/mstest/basic.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import http from 'http';
2626
import { test, expect } from '../baseTest';
2727
import httpProxy from 'http-proxy';
2828

29+
test.use({ testMode: 'mstest' });
30+
2931
test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
3032
const result = await runTest({
3133
'ExampleTests.cs': `

src/Playwright.TestingHarnessTest/tests/nunit/basic.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import http from 'http';
2626
import { test, expect } from '../baseTest';
2727
import httpProxy from 'http-proxy';
2828

29+
test.use({ testMode: 'nunit' });
30+
2931
test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
3032
const result = await runTest({
3133
'ExampleTests.cs': `

src/Playwright.TestingHarnessTest/tests/xunit/basic.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import http from 'http';
2626
import { test, expect } from '../baseTest';
2727
import httpProxy from 'http-proxy';
2828

29+
test.use({ testMode: 'xunit' });
30+
2931
test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
3032
const result = await runTest({
3133
'ExampleTests.cs': `

0 commit comments

Comments
 (0)