Skip to content

Commit

Permalink
Playwright dotnet new Template (#1660)
Browse files Browse the repository at this point in the history
* Playwright Template

* Add template.json files

* Fix
  • Loading branch information
thomhurst authored Jan 23, 2025
1 parent d4863fc commit ac04d33
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 41 deletions.
10 changes: 2 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,8 @@
<PackageVersion Include="Polly" Version="8.5.1" />
<PackageVersion Include="Polyfill" Version="7.13.0" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="Sourcy.DotNet" Version="0.0.85">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Sourcy.Git" Version="0.0.85">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageVersion>
<PackageVersion Include="Sourcy.DotNet" Version="0.0.85" />
<PackageVersion Include="Sourcy.Git" Version="0.0.85" />
<PackageVersion Include="StreamJsonRpc" Version="2.20.20" />
<PackageVersion Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.1" />
Expand Down
5 changes: 2 additions & 3 deletions TUnit.Pipeline/Modules/RunPlaywrightTestsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ public class RunPlaywrightTestsModule : Module<CommandResult>
{
protected override async Task<CommandResult?> ExecuteAsync(IPipelineContext context, CancellationToken cancellationToken)
{
var project = context.Git().RootDirectory.FindFile(x => x.Name == "TUnit.Playwright.Tests.csproj").AssertExists();
var project = Sourcy.DotNet.Projects.TUnit_Templates__content__TUnit_Playwright__TestProject;

return await context.DotNet().Test(new DotNetTestOptions(project)
return await context.DotNet().Test(new DotNetTestOptions(project.FullName)
{
NoBuild = true,
Configuration = Configuration.Release,
Framework = Environment.GetEnvironmentVariable("NET_VERSION"),
EnvironmentVariables = new Dictionary<string, string?>
{
["DISABLE_GITHUB_REPORTER"] = "true",
Expand Down
17 changes: 0 additions & 17 deletions TUnit.Playwright.Tests/TUnit.Playwright.Tests.csproj

This file was deleted.

13 changes: 13 additions & 0 deletions TUnit.Templates/.idea/.idea.TUnit.dir/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions TUnit.Templates/.idea/.idea.TUnit.dir/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions TUnit.Templates/.idea/.idea.TUnit.dir/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions TUnit.Templates/.idea/.idea.TUnit.dir/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Tom Longhurst",
"description": "A template for testing an ASP.NET Core project with TUnit",
"classifications": [
"Test",
"TUnit",
"Asp",
"ASP.NET"
],
"name": "TUnit ASP.NET Core Project",
"identity": "TUnit.Test.AspNet",
"groupIdentity": "TUnit",
"shortName": "TUnit.AspNet",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "TestProject",
"preferNameDirectory": true
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Tom Longhurst",
"description": "A template for testing using Playwright with TUnit",
"classifications": [
"Test",
"TUnit",
"Playwright"
],
"name": "TUnit Playwright Project",
"identity": "TUnit.Test.Playwright",
"groupIdentity": "TUnit",
"shortName": "TUnit.Playwright",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "TestProject",
"preferNameDirectory": true
}

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Diagnostics;

namespace TUnit.Playwright.Tests;
namespace TestProject;

public class Hooks
{
[Before(Assembly)]
[Before(TestSession)]
public static void InstallPlaywright()
{
if (Debugger.IsAttached)
Expand Down
14 changes: 14 additions & 0 deletions TUnit.Templates/content/TUnit.Playwright/TestProject.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TUnit.Playwright" Version="0.7.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using System.Text.RegularExpressions;
using TUnit.Playwright;

namespace TUnit.Playwright.Tests;
namespace TestProject;

public class Tests : PageTest
{
[Test]
public async Task Test()
{
await Page.GotoAsync("https://www.github.com/thomhurst/TUnit");
}

[Test]
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingtoTheIntroPage()
{
await Page.GotoAsync("https://playwright.dev");

Expand Down
4 changes: 2 additions & 2 deletions TUnit.Templates/content/TUnit/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"Test",
"TUnit"
],
"name": "TUnit Test Project",
"identity": "TUnit.Test.Project",
"name": "TUnit Mixed Test Project",
"identity": "TUnit.Test.Mixed",
"groupIdentity": "TUnit",
"shortName": "TUnit",
"tags": {
Expand Down
7 changes: 5 additions & 2 deletions TUnit.sln
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TUnit.Playwright", "TUnit.Playwright\TUnit.Playwright.csproj", "{33C13E01-6FC8-4118-A4EB-7C63E6612248}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TUnit.Playwright.Tests", "TUnit.Playwright.Tests\TUnit.Playwright.Tests.csproj", "{EB92E3E9-A192-4DDD-9B10-4355D74BD119}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject", "TUnit.Templates\content\TUnit.Playwright\TestProject.csproj", "{EB92E3E9-A192-4DDD-9B10-4355D74BD119}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SourceGenerators", "SourceGenerators", "{6F7B9D8E-4539-42BC-BE0B-E5BE70ED9473}"
EndProject
Expand All @@ -81,6 +81,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject", "TUnit.Templa
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApp", "TUnit.Templates\content\TUnit.AspNet\WebApp\WebApp.csproj", "{D778BF96-702F-4A59-A2D5-E348A3320E58}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Playwright", "Playwright", "{32F534AB-F8C1-42D0-BFB3-9270CEA6C3F3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -228,7 +230,6 @@ Global
{BD0CDBA0-8A38-45A2-8581-043A13A34D67} = {62AD1EAF-43C4-4AC0-B9FA-CD59739B3850}
{2DE2A1F9-2A87-4FA8-8D62-0B60093DA604} = {62AD1EAF-43C4-4AC0-B9FA-CD59739B3850}
{33C13E01-6FC8-4118-A4EB-7C63E6612248} = {1B56B580-4D59-4E83-9F80-467D58DADAC1}
{EB92E3E9-A192-4DDD-9B10-4355D74BD119} = {62AD1EAF-43C4-4AC0-B9FA-CD59739B3850}
{BECB04A9-C731-4AC0-B76B-36382BFE77AA} = {6F7B9D8E-4539-42BC-BE0B-E5BE70ED9473}
{1EF4041E-CBD0-49C9-9D4B-56E16B653170} = {6F7B9D8E-4539-42BC-BE0B-E5BE70ED9473}
{C1320FF8-0AAB-4C41-A87B-841AFB0A512A} = {6F7B9D8E-4539-42BC-BE0B-E5BE70ED9473}
Expand All @@ -240,6 +241,8 @@ Global
{23F41068-7C7E-435C-B6AB-4258B6380DC2} = {835A7825-FC06-46E2-B3B1-2BF791A22B97}
{2BCFDB65-AF9F-4CC4-B215-4C0035906F2A} = {23F41068-7C7E-435C-B6AB-4258B6380DC2}
{D778BF96-702F-4A59-A2D5-E348A3320E58} = {23F41068-7C7E-435C-B6AB-4258B6380DC2}
{32F534AB-F8C1-42D0-BFB3-9270CEA6C3F3} = {835A7825-FC06-46E2-B3B1-2BF791A22B97}
{EB92E3E9-A192-4DDD-9B10-4355D74BD119} = {32F534AB-F8C1-42D0-BFB3-9270CEA6C3F3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {109D285A-36B3-4503-BCDF-8E26FB0E2C5B}
Expand Down

0 comments on commit ac04d33

Please sign in to comment.