test262harness - Test262Harness 1.0.0-preview-20250317-0702

Test262 Harness for .NET

PM> Install-Package Test262Harness -Version 1.0.0-preview-20250317-0702 -Source https://www.myget.org/F/test262harness/api/v3/index.json

Copy to clipboard

> nuget.exe install Test262Harness -Version 1.0.0-preview-20250317-0702 -Source https://www.myget.org/F/test262harness/api/v3/index.json

Copy to clipboard

> dotnet add package Test262Harness --version 1.0.0-preview-20250317-0702 --source https://www.myget.org/F/test262harness/api/v3/index.json

Copy to clipboard
<PackageReference Include="Test262Harness" Version="1.0.0-preview-20250317-0702" />
Copy to clipboard
source https://www.myget.org/F/test262harness/api/v3/index.json

nuget Test262Harness  ~> 1.0.0-preview-20250317-0702
Copy to clipboard

> choco install Test262Harness --version 1.0.0-preview-20250317-0702 --source https://www.myget.org/F/test262harness/api/v2

Copy to clipboard
Import-Module PowerShellGet
Register-PSRepository -Name "test262harness" -SourceLocation "https://www.myget.org/F/test262harness/api/v2"
Install-Module -Name "Test262Harness" -RequiredVersion "1.0.0-preview-20250317-0702" -Repository "test262harness" -AllowPreRelease
Copy to clipboard

Build NuGet NuGet MyGet

Test262-Harness-dotnet

This is a .NET test runner for Test262: ECMAScript Test Suite. It includes parsing and downloading logic for the test suite in package Test262Harness and test suite generator functionality via CLI too, Test262Harness.Console

Usage

Following projects are utilizing the test suite generation and show how to create NUnit based test suite that is being generated by downloaded snapshot from test262 GitHub repository.

  • Jint
    • Generates NUnit test suite to ensure compliance, suite can be run in parallel for faster feedback loop
  • esprima-dotnet
    • Generates NUnit test suite for parsing tests, also has custom console logic to compare allow-list.txt for problematic files and progress getting the to parse properly
  • acornima
    • Generates NUnit test suite for parsing tests

First you need need to install the required package to your test project, it should look similar to this:

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
    <PackageReference Include="NUnit" Version="4.0.1" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
    <PackageReference Include="Test262Harness" Version="1.0.0" />
  </ItemGroup>

Next you will need a configuration, similar to this (also check the configuration format section):

Test262Harness.settings.json example

{
  "SuiteGitSha": "28b31c0bf1960878abb36ab8597a0cae224a684d",
  "TargetPath": "./Generated",
  "Namespace": "My.Tests.Test262",
  "ExcludedFeatures": [
    "Atomics",
    "Temporal"
  ],
  "ExcludedFlags": [
    "async" 
  ],
  "ExcludedDirectories": [
    "annexB",
    "intl402"
  ],
  "ExcludedFiles": [
    "language/expressions/object/dstr-async-gen-meth-*",
    "language/expressions/assignment/fn-name-lhs-cover.js"
  ]
}

You need to create minimal test file stub to initialize your testing target, example from Jint project.

using System;
using System.IO;
using Esprima;
using Jint.Native;
using Jint.Native.ArrayBuffer;
using Jint.Runtime;
using Jint.Runtime.Descriptors;
using Jint.Runtime.Interop;
using Test262Harness;

namespace Jint.Tests.Test262;

public static partial class State
{
    /// <summary>
    /// Pre-compiled scripts for faster execution.
    /// </summary>
    public static readonly Dictionary<string, Script> Sources = new(StringComparer.OrdinalIgnoreCase);
}

/// <summary>
/// Handles initializing testing state.
/// </summary>
public partial class TestHarness
{
    private static partial Task InitializeCustomState()
    {
        foreach (var file in State.HarnessFiles)
        {
            var source = file.Program;
            State.Sources[Path.GetFileName(file.FileName)] = new JavaScriptParser(source, new ParserOptions(file.FileName)).ParseScript();
        }

        return Task.CompletedTask;
    }
}

public abstract partial class Test262Test
{
    private Engine BuildTestExecutor(Test262File file)
    {
        var engine = new Engine(cfg =>
        {
            var relativePath = Path.GetDirectoryName(file.FileName);
            cfg.EnableModules(new Test262ModuleLoader(State.Test262Stream.Options.FileSystem, relativePath));
        });

        if (file.Flags.Contains("raw"))
        {
            // nothing should be loaded
            return engine;
        }

        engine.Execute(State.Sources["assert.js"]);
        engine.Execute(State.Sources["sta.js"]);

        // initialize engine with Test262 expected host defined functions here
        // https://github.com/tc39/test262/blob/main/INTERPRETING.md#host-defined-functions

        engine.SetValue("print", new ClrFunction(engine, "print", (_, args) => TypeConverter.ToString(args.At(0))));
        // and more...

        // the cinded files that that are expected
        foreach (var include in file.Includes)
        {
            engine.Execute(State.Sources[include]);
        }

        return engine;
    }

    private static void ExecuteTest(Engine engine, Test262File file)
    {
        if (file.Type == ProgramType.Module)
        {
            engine.AddModule(file.FileName, builder => builder.AddSource(file.Program));
            engine.ImportModule(file.FileName);
        }
        else
        {
            engine.Execute(new JavaScriptParser(file.Program, new ParserOptions(file.FileName)).ParseScript());
        }
    }

    private partial bool ShouldThrow(Test262File testCase, bool strict)
    {
        return testCase.Negative;
    }
}

And also the CLI tool for generating the test suite, run this in you test project directory.

dotnet tool add Test262Harness.Console

When everything is installed, you should be able to run:

dotnet tool restore
dotnet test262 generate

Test262Harness.settings.json configuration file

List of most important things you can tweak in configuration file:

Key Default Description
SuiteGitSha none The GitHub commit to use when downloading the test suite
SuiteDirectory none Alternatively, you can point to local repository root
TargetPath none Where to generate the file to
Namespace Test262Harness.TestSuite Namespace for the generated source files
ExcludedFeatures [] Any feature you want to ignore
ExcludedFlags [] Any flag you want to ignore
ExcludedDirectories [] Any sub-directory you would like to ignore, for example annexB
ExcludedFiles [] List of specific files you would like to ignore

Exclusion maps to setting [Ignore] attribute in test suite.

Branches and releases

  • .NETFramework 8.0
    • SharpZipLib (>= 1.4.2)
    • YamlDotNet (>= 16.3.0)
    • Zio (>= 0.20.0)
    • ZString (>= 2.6.0)
  • .NETStandard 2.0
    • SharpZipLib (>= 1.4.2)
    • System.Memory (>= 4.6.0)
    • YamlDotNet (>= 16.3.0)
    • Zio (>= 0.20.0)
    • ZString (>= 2.6.0)
  • .NETFramework 8.0: 8.0.0.0
  • .NETStandard 2.0: 2.0.0.0

Owners

Marko Lahma

Authors

Marko Lahma

Project URL

https://github.com/lahma/test262-harness-dotnet

License

Unknown

Tags

test262,javascript,ecmascript,test,harness

Info

8404 total downloads
92 downloads for version 1.0.0-preview-20250317-0702
Download (40.88 KB)
Found on the current feed only

Package history

Version Size Last updated Downloads Mirrored?
1.0.0-preview-20260420-1723 40.9 KB Mon, 20 Apr 2026 17:23:53 GMT 3
1.0.0-preview-20260420-1716 40.89 KB Mon, 20 Apr 2026 17:17:19 GMT 3
1.0.0-preview-20260413-0418 40.9 KB Mon, 13 Apr 2026 04:19:13 GMT 4
1.0.0-preview-20260407-1816 40.9 KB Tue, 07 Apr 2026 18:17:05 GMT 8
1.0.0-preview-20260406-0638 40.9 KB Mon, 06 Apr 2026 06:38:36 GMT 5
1.0.0-preview-20260330-0445 40.9 KB Mon, 30 Mar 2026 04:46:43 GMT 8
1.0.0-preview-20260330-0413 40.9 KB Mon, 30 Mar 2026 04:14:38 GMT 4
1.0.0-preview-20260325-1549 40.9 KB Wed, 25 Mar 2026 15:49:52 GMT 3
1.0.0-preview-20260325-0521 40.84 KB Wed, 25 Mar 2026 05:21:43 GMT 5
1.0.0-preview-20260325-0517 40.84 KB Wed, 25 Mar 2026 05:17:34 GMT 8
1.0.0-preview-20260325-0503 40.83 KB Wed, 25 Mar 2026 05:03:27 GMT 4
1.0.0-preview-20260325-0502 40.83 KB Wed, 25 Mar 2026 05:03:16 GMT 5
1.0.0-preview-20260112-0736 40.83 KB Mon, 12 Jan 2026 07:36:51 GMT 11
1.0.0-preview-20251222-1649 40.83 KB Mon, 22 Dec 2025 16:49:53 GMT 14
1.0.0-preview-20251208-0546 40.85 KB Mon, 08 Dec 2025 05:46:45 GMT 26
1.0.0-preview-20251208-0545 40.83 KB Mon, 08 Dec 2025 05:45:41 GMT 18
1.0.0-preview-20251201-0553 40.84 KB Mon, 01 Dec 2025 05:53:48 GMT 21
1.0.0-preview-20251201-0312 40.84 KB Mon, 01 Dec 2025 03:12:34 GMT 20
1.0.0-preview-20251127-1843 40.85 KB Thu, 27 Nov 2025 18:43:35 GMT 18
1.0.0-preview-20251124-0442 40.87 KB Mon, 24 Nov 2025 04:42:55 GMT 25
1.0.0-preview-20251124-0441 40.85 KB Mon, 24 Nov 2025 04:41:45 GMT 21
1.0.0-preview-20251124-0440 40.85 KB Mon, 24 Nov 2025 04:40:58 GMT 25
1.0.0-preview-20251110-0433 40.85 KB Mon, 10 Nov 2025 04:33:59 GMT 41
1.0.0-preview-20251103-0414 40.84 KB Mon, 03 Nov 2025 04:15:20 GMT 39
1.0.0-preview-20251015-1455 40.86 KB Wed, 15 Oct 2025 14:55:36 GMT 37
1.0.0-preview-20251015-1454 40.84 KB Wed, 15 Oct 2025 14:55:25 GMT 42
1.0.0-preview-20250915-0529 40.85 KB Mon, 15 Sep 2025 05:29:51 GMT 56
1.0.0-preview-20250908-0840 40.85 KB Mon, 08 Sep 2025 08:40:47 GMT 75
1.0.0-preview-20250823-0523 40.86 KB Sat, 23 Aug 2025 05:23:53 GMT 77
1.0.0-preview-20250818-0517 40.85 KB Mon, 18 Aug 2025 05:18:11 GMT 81
1.0.0-preview-20250818-0514 40.84 KB Mon, 18 Aug 2025 05:14:55 GMT 81
1.0.0-preview-20250818-0503 40.85 KB Mon, 18 Aug 2025 05:04:04 GMT 68
1.0.0-preview-20250721-0944 40.86 KB Mon, 21 Jul 2025 09:45:16 GMT 74
1.0.0-preview-20250623-0509 40.85 KB Mon, 23 Jun 2025 05:10:18 GMT 72
1.0.0-preview-20250616-0641 40.87 KB Mon, 16 Jun 2025 06:42:22 GMT 67
1.0.0-preview-20250609-0552 40.86 KB Mon, 09 Jun 2025 05:53:12 GMT 80
1.0.0-preview-20250602-0407 40.85 KB Mon, 02 Jun 2025 04:07:38 GMT 66
1.0.0-preview-20250526-0616 40.85 KB Mon, 26 May 2025 06:16:52 GMT 89
1.0.0-preview-20250517-1000 40.85 KB Sat, 17 May 2025 10:00:31 GMT 74
1.0.0-preview-20250428-0559 40.87 KB Mon, 28 Apr 2025 06:00:15 GMT 79
1.0.0-preview-20250421-0609 40.87 KB Mon, 21 Apr 2025 06:10:12 GMT 88
1.0.0-preview-20250414-0636 40.86 KB Mon, 14 Apr 2025 06:36:47 GMT 84
1.0.0-preview-20250414-0633 40.86 KB Mon, 14 Apr 2025 06:33:33 GMT 87
1.0.0-preview-20250414-0632 40.85 KB Mon, 14 Apr 2025 06:32:35 GMT 75
1.0.0-preview-20250317-0702 40.88 KB Mon, 17 Mar 2025 07:02:44 GMT 92
1.0.0-preview-20250317-0657 40.85 KB Mon, 17 Mar 2025 06:58:10 GMT 87
1.0.0-preview-20250217-0536 40.86 KB Mon, 17 Feb 2025 05:36:51 GMT 81
1.0.0-preview-20250210-0710 40.79 KB Mon, 10 Feb 2025 07:10:57 GMT 95
1.0.0-preview-20250203-0725 40.79 KB Mon, 03 Feb 2025 07:25:59 GMT 75
1.0.0-preview-20250203-0720 40.79 KB Mon, 03 Feb 2025 07:20:34 GMT 77
1.0.0-preview-20250128-0615 40.8 KB Tue, 28 Jan 2025 06:16:02 GMT 86
1.0.0-preview-20250128-0614 40.79 KB Tue, 28 Jan 2025 06:14:59 GMT 90
1.0.0-preview-20250128-0606 39.79 KB Tue, 28 Jan 2025 06:06:54 GMT 73
1.0.0-preview-20250113-0714 57.53 KB Mon, 13 Jan 2025 07:15:01 GMT 93
1.0.0-preview-20250113-0713 57.52 KB Mon, 13 Jan 2025 07:14:10 GMT 89
1.0.0-preview-20250106-0610 57.52 KB Mon, 06 Jan 2025 06:10:54 GMT 94
1.0.0-preview-20250106-0609 57.52 KB Mon, 06 Jan 2025 06:10:15 GMT 91
1.0.0-preview-20241230-0923 57.54 KB Mon, 30 Dec 2024 09:23:59 GMT 77
1.0.0-preview-20241230-0921 57.53 KB Mon, 30 Dec 2024 09:21:39 GMT 92
1.0.0-preview-20241223-0800 57.53 KB Mon, 23 Dec 2024 08:00:42 GMT 78
1.0.0-preview-20241223-0759 57.53 KB Mon, 23 Dec 2024 08:00:02 GMT 80
1.0.0-preview-20241223-0754 57.52 KB Mon, 23 Dec 2024 07:54:43 GMT 94
1.0.0-preview-20241223-0753 57.52 KB Mon, 23 Dec 2024 07:54:09 GMT 83
1.0.0-preview-20241216-0300 57.53 KB Mon, 16 Dec 2024 03:01:21 GMT 95
1.0.0-preview-20241209-0620 57.55 KB Mon, 09 Dec 2024 06:21:15 GMT 74
1.0.0-preview-20241209-0619 57.53 KB Mon, 09 Dec 2024 06:20:28 GMT 91
1.0.0-preview-20241202-1104 57.53 KB Mon, 02 Dec 2024 11:05:02 GMT 73
1.0.0-preview-20241202-0657 57.53 KB Mon, 02 Dec 2024 06:58:15 GMT 90
1.0.0-preview-20241125-1547 57.53 KB Mon, 25 Nov 2024 15:48:15 GMT 69
1.0.0-preview-20241125-1546 57.53 KB Mon, 25 Nov 2024 15:47:16 GMT 88
1.0.0-preview-20241118-0716 57.54 KB Mon, 18 Nov 2024 07:17:32 GMT 91
1.0.0-preview-20241111-0718 57.55 KB Mon, 11 Nov 2024 07:19:30 GMT 75
1.0.0-preview-20241111-0515 57.55 KB Mon, 11 Nov 2024 05:15:35 GMT 89
1.0.0-preview-20241111-0511 57.53 KB Mon, 11 Nov 2024 05:12:14 GMT 89
1.0.0-preview-20241014-0600 57.53 KB Mon, 14 Oct 2024 06:01:04 GMT 77
1.0.0-preview-20241007-0504 57.54 KB Mon, 07 Oct 2024 05:04:43 GMT 76
1.0.0-preview-20240930-0559 57.54 KB Mon, 30 Sep 2024 05:59:42 GMT 77
1.0.0-preview-20240916-0605 57.54 KB Mon, 16 Sep 2024 06:05:57 GMT 88
1.0.0-preview-20240916-0604 57.54 KB Mon, 16 Sep 2024 06:05:06 GMT 97
1.0.0-preview-20240910-0525 57.53 KB Tue, 10 Sep 2024 05:25:56 GMT 99
1.0.0-preview-20240909-0532 57.53 KB Mon, 09 Sep 2024 05:33:12 GMT 80
1.0.0-preview-20240902-0511 57.53 KB Mon, 02 Sep 2024 05:12:22 GMT 89
1.0.0-preview-20240902-0510 57.53 KB Mon, 02 Sep 2024 05:11:23 GMT 93
1.0.0-preview-20240826-0405 57.55 KB Mon, 26 Aug 2024 04:06:03 GMT 78
1.0.0-preview-20240826-0322 57.54 KB Mon, 26 Aug 2024 03:22:59 GMT 78
1.0.0-preview-20240819-0324 57.54 KB Mon, 19 Aug 2024 03:25:12 GMT 89
1.0.0-preview-20240805-0541 57.51 KB Mon, 05 Aug 2024 05:42:03 GMT 87
1.0.0-preview-20240731-0730 57.54 KB Wed, 31 Jul 2024 07:30:41 GMT 86
1.0.0-preview-20240729-0910 57.55 KB Mon, 29 Jul 2024 09:11:17 GMT 71
1.0.0-preview-20240722-0510 57.54 KB Mon, 22 Jul 2024 05:10:38 GMT 81
1.0.0-preview-20240715-0802 57.53 KB Mon, 15 Jul 2024 08:03:15 GMT 79
1.0.0-preview-20240715-0609 53.94 KB Mon, 15 Jul 2024 06:10:22 GMT 94
1.0.0-preview-20240715-0608 53.93 KB Mon, 15 Jul 2024 06:09:10 GMT 87
1.0.0-preview-20240624-0519 53.95 KB Mon, 24 Jun 2024 05:20:23 GMT 71
1.0.0-preview-20240624-0518 53.95 KB Mon, 24 Jun 2024 05:18:39 GMT 90
1.0.0-preview-20240617-0501 53.94 KB Mon, 17 Jun 2024 05:02:05 GMT 89
1.0.0-preview-20240603-0428 53.93 KB Mon, 03 Jun 2024 04:28:50 GMT 78
1.0.0-preview-20240603-0413 53.94 KB Mon, 03 Jun 2024 04:13:48 GMT 71
1.0.0-preview-20240603-0412 53.94 KB Mon, 03 Jun 2024 04:13:22 GMT 95
1.0.0-preview-20240527-0413 53.95 KB Mon, 27 May 2024 04:14:05 GMT 72
1.0.0-preview-20240519-0655 53.94 KB Sun, 19 May 2024 06:55:34 GMT 86
1.0.0-preview-20240216-1831 53.59 KB Fri, 16 Feb 2024 18:32:00 GMT 90
0.0.23-preview-20240216-1828 53.61 KB Fri, 16 Feb 2024 18:29:00 GMT 87
0.0.23-preview-20240216-1815 54.36 KB Fri, 16 Feb 2024 18:16:22 GMT 79
0.0.23-preview-20240216-1806 54.37 KB Fri, 16 Feb 2024 18:07:17 GMT 82
0.0.23-preview-20231228-1625 54.37 KB Thu, 28 Dec 2023 16:26:56 GMT 83
0.0.22-preview-20230810-1927 35.12 KB Thu, 10 Aug 2023 19:28:00 GMT 90
0.0.22-preview-20230810-0754 33.25 KB Thu, 10 Aug 2023 07:55:00 GMT 86
0.0.22-preview-20230507-1809 33.5 KB Sun, 07 May 2023 18:10:21 GMT 82
0.0.22-preview-20220925-0721 33.26 KB Sun, 25 Sep 2022 07:22:01 GMT 92
0.0.19-preview-20220918-0624 33.28 KB Sun, 18 Sep 2022 06:25:39 GMT 81
0.0.19-preview-20220807-0752 33.41 KB Sun, 07 Aug 2022 07:53:12 GMT 86
0.0.19-preview-20220807-0731 33.21 KB Sun, 07 Aug 2022 07:34:34 GMT 95
0.0.19-preview-20220807-0723 33.21 KB Sun, 07 Aug 2022 07:24:18 GMT 74
0.0.19-preview-20220730-1217 33.55 KB Sat, 30 Jul 2022 12:18:08 GMT 100
0.0.19-preview-20220730-1213 33.54 KB Sat, 30 Jul 2022 12:13:37 GMT 88
0.0.19-preview-20220730-0917 33.42 KB Sat, 30 Jul 2022 09:18:10 GMT 85
0.0.19-preview-20220730-0914 33.42 KB Sat, 30 Jul 2022 09:14:24 GMT 90
0.0.17-preview-20220730-0911 33.43 KB Sat, 30 Jul 2022 09:11:32 GMT 80
0.0.17-preview-20220526-1709 33.44 KB Thu, 26 May 2022 17:10:13 GMT 86
0.0.17-preview-20220526-1659 33.54 KB Thu, 26 May 2022 16:59:44 GMT 80
0.0.16 33.4 KB Thu, 26 May 2022 16:44:59 GMT 88