Skip to content

Commit

Permalink
chore: re-introduce mocha for running legacy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MangelMaxime committed Jun 20, 2024
1 parent 6c08644 commit d9f38ab
Show file tree
Hide file tree
Showing 3 changed files with 331 additions and 31 deletions.
85 changes: 58 additions & 27 deletions build/Commands/Test.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,6 @@ let cleanUp (dir: string) =

let private outDir = "fableBuild"

let private runTestForJavaScript isWatch cwd =
let fableArgs =
CmdLine.concat
[
CmdLine.empty
|> CmdLine.appendRaw "fable"
|> CmdLine.appendPrefix "--outDir" outDir
|> CmdLine.appendRaw "--noCache"
|> CmdLine.appendRaw "--test:MSBuildCracker"

if isWatch then
CmdLine.empty
|> CmdLine.appendRaw "--watch"
|> CmdLine.appendRaw "--runScript"
else
CmdLine.empty |> CmdLine.appendRaw "--runScript"
]
|> CmdLine.toString

Command.Run("dotnet", fableArgs, workingDirectory = cwd)

type TestJavaScriptCommand() =
inherit Command<TestSettings>()
interface ICommandLimiter<TestSettings>
Expand All @@ -52,9 +31,30 @@ type TestJavaScriptCommand() =
cleanUp
VirtualWorkspace.tests.``Thoth.Json.Tests.JavaScript``.fableBuild.``.``

runTestForJavaScript
settings.IsWatch
Workspace.tests.``Thoth.Json.Tests.JavaScript``.``.``
let fableArgs =
CmdLine.concat
[
CmdLine.empty
|> CmdLine.appendRaw "fable"
|> CmdLine.appendPrefix "--outDir" outDir
|> CmdLine.appendRaw "--noCache"
|> CmdLine.appendRaw "--test:MSBuildCracker"

if settings.IsWatch then
CmdLine.empty
|> CmdLine.appendRaw "--watch"
|> CmdLine.appendRaw "--runScript"
else
CmdLine.empty |> CmdLine.appendRaw "--runScript"
]
|> CmdLine.toString

Command.Run(
"dotnet",
fableArgs,
workingDirectory =
Workspace.tests.``Thoth.Json.Tests.JavaScript``.``.``
)

0

Expand Down Expand Up @@ -112,9 +112,40 @@ type TestLegacyCommand() =
interface ICommandLimiter<TestSettings>

override _.Execute(context: CommandContext, settings: TestSettings) =
runTestForJavaScript
settings.IsWatch
Workspace.tests.``Thoth.Json.Tests.Legacy``.``.``
let mochaComand =
CmdLine.empty
|> CmdLine.appendRaw "npx"
|> CmdLine.appendRaw "mocha"
|> CmdLine.appendRaw outDir
|> CmdLine.appendPrefix "--reporter" "dot"
|> CmdLine.toString

let fableArgs =
CmdLine.concat
[
CmdLine.empty
|> CmdLine.appendRaw "fable"
|> CmdLine.appendPrefix "--outDir" outDir
|> CmdLine.appendRaw "--noCache"
|> CmdLine.appendRaw "--test:MSBuildCracker"

if settings.IsWatch then
CmdLine.empty
|> CmdLine.appendRaw "--watch"
|> CmdLine.appendRaw "--runWatch"
|> CmdLine.appendRaw mochaComand
else
CmdLine.empty
|> CmdLine.appendRaw "--run"
|> CmdLine.appendRaw mochaComand
]
|> CmdLine.toString

Command.Run(
"dotnet",
fableArgs,
workingDirectory = Workspace.tests.``Thoth.Json.Tests.Legacy``.``.``
)

0

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"changelog-parser": "^3.0.1",
"fable-font": "^1.0.1",
"gh-pages": "^6.1.0",
"mocha": "^10.4.0",
"prismjs": "^1.29.0",
"typescript": "^5.4.5"
}
Expand Down
Loading

0 comments on commit d9f38ab

Please sign in to comment.