Skip to content
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 @@ -10,6 +10,9 @@ namespace OJS.Workers.ExecutionStrategies.Models
public class JsonExecutionResult
{
private const string InvalidJsonReplace = "]}[},!^@,Invalid,!^@,{]{[";
private const string MissingJsonStructureError = "Invalid console output! Please make sure there are no console.log statements in the solution. The system expects JSON output from Mocha test results.";
private const string MissingPassingFieldError = "Invalid console output! Please make sure there are no console.log statements in the solution. Missing or invalid 'passing' array in test results.";
private const string MissingFailuresFieldError = "Invalid console output! Please make sure there are no console.log statements in the solution. Missing or invalid 'failures' array with 'err.message' fields.";

public IList<string> TestErrors { get; set; }

Expand Down Expand Up @@ -68,7 +71,7 @@ public static JsonExecutionResult Parse(string result, bool forceErrorExtracting
}
catch
{
error = "Invalid console output!";
error = MissingJsonStructureError;
}

var testsIndexes = new List<int>();
Expand All @@ -80,7 +83,7 @@ public static JsonExecutionResult Parse(string result, bool forceErrorExtracting
}
catch
{
error = "Invalid console output!";
error = MissingPassingFieldError;
}
}

Expand All @@ -97,7 +100,7 @@ public static JsonExecutionResult Parse(string result, bool forceErrorExtracting
}
catch
{
error = "Invalid console output!";
error = MissingFailuresFieldError;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,18 @@ protected override async Task<IExecutionResult<TestResult>> ExecuteAgainstTestsI
protected static string FormatTests(IEnumerable<TestContext> tests, bool isTypeScript)
{
var formattedTests = new List<string>();
var testCounter = 1;

foreach (var test in tests)
{
// Use simple sequential test names
var testName = $"Test{testCounter}";
var testContent = test.Input.Trim();

// Format the test with proper it() wrapper
var formattedTest = $@"
{(isTypeScript ? "// @ts-ignore" : "")}
it('{testName}', function () {{
{testContent}
}})";
{testContent}";

formattedTests.Add(formattedTest);
testCounter++;
}

// Join all formatted tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,24 @@ protected override async Task<IExecutionResult<TestResult>> ExecuteAgainstTestsI
{
SaveZipSubmission(executionContext.FileContent, this.WorkingDirectory);

var esBuildExecutionArguments = new[]
{
"src/index.ts",
"--bundle",
"--platform=node",
"--format=cjs",
"--target=node21",
"--packages=external",
"--drop:console",
"--outfile=dist/app.bundle.js"
};

var executor = this.CreateStandardExecutor();
var bundleResult = await executor.Execute(
this.Settings.EsBuildModulePath,
executionContext.TimeLimit,
executionContext.MemoryLimit,
executionArguments: ["src/index.ts", "--bundle", "--platform=node", "--format=cjs", "--target=node21", "--packages=external", "--outfile=dist/app.bundle.js"],
executionArguments: esBuildExecutionArguments,
workingDirectory: this.WorkingDirectory,
cancellationToken: cancellationToken);

Expand Down
Loading