Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: isolate test-projects from each-other #3099

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,27 @@
<Import Project="../Common/SignAssembly.props" />

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
<ProjectReference Include="..\Playwright\Playwright.csproj" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />

<!-- MSTest -->
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" Condition="'$(TEST_MODE)' == 'mstest'" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" Condition="'$(TEST_MODE)' == 'mstest'" />

<!-- NUnit -->
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" Condition="'$(TEST_MODE)' == 'nunit'" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" Condition="'$(TEST_MODE)' == 'nunit'" />

<!-- xUnit -->
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" Condition="'$(TEST_MODE)' == 'xunit'" />
<PackageReference Include="xunit" Version="2.9.2" Condition="'$(TEST_MODE)' == 'xunit'" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" Condition="'$(TEST_MODE)' == 'xunit'" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Playwright\Playwright.csproj" />
<ProjectReference Include="..\Playwright.MSTest\Playwright.MSTest.csproj" />
<ProjectReference Include="..\Playwright.NUnit\Playwright.NUnit.csproj" />
<ProjectReference Include="..\Playwright.Xunit\Playwright.Xunit.csproj" />
<Compile Remove="**/*.cs" />
<Compile Include="$(PWTEST_TEST_DIR)/*.cs" />
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions src/Playwright.TestingHarnessTest/tests/baseTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ type RunResult = {
}

export const test = base.extend<{
testMode: 'nunit' | 'mstest' | 'xunit';
runTest: (files: Record<string, string>, command: string, env?: NodeJS.ProcessEnv) => Promise<RunResult>;
}>({
runTest: async ({ }, use, testInfo) => {
testMode: null,
runTest: async ({ testMode }, use, testInfo) => {
const testResults: RunResult[] = [];
await use(async (files, command, env) => {
const testDir = testInfo.outputPath();
Expand All @@ -34,7 +36,9 @@ export const test = base.extend<{
env: {
...process.env,
...env,
NODE_OPTIONS: undefined
NODE_OPTIONS: undefined,
TEST_MODE: testMode,
PWTEST_TEST_DIR: testDir,
},
stdio: 'pipe',
});
Expand Down
2 changes: 2 additions & 0 deletions src/Playwright.TestingHarnessTest/tests/mstest/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import http from 'http';
import { test, expect } from '../baseTest';
import httpProxy from 'http-proxy';

test.use({ testMode: 'mstest' });

test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
Expand Down
2 changes: 2 additions & 0 deletions src/Playwright.TestingHarnessTest/tests/nunit/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import http from 'http';
import { test, expect } from '../baseTest';
import httpProxy from 'http-proxy';

test.use({ testMode: 'nunit' });

test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
Expand Down
2 changes: 2 additions & 0 deletions src/Playwright.TestingHarnessTest/tests/xunit/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import http from 'http';
import { test, expect } from '../baseTest';
import httpProxy from 'http-proxy';

test.use({ testMode: 'xunit' });

test('should be able to forward DEBUG=pw:api env var', async ({ runTest }) => {
const result = await runTest({
'ExampleTests.cs': `
Expand Down
Loading