Closed giuliohome closed 2 weeks ago
Note that this PR does not address the separate question asked here: https://github.com/SAFE-Stack/SAFE-template/issues/615#issuecomment-2169434320
To answer that separate question as well, follow these steps (based on this Fable.Mocha paragraph):
npm install --save-dev mocha
.{
"type": "module",
"scripts": {
"pretest": "dotnet fable Client.Tests.fsproj -o dist/tests",
"test": "mocha dist/tests"
},
"devDependencies": {
"mocha": "^9.2.2"
}
}
Run npm test
Finally modify the Build.fs as follows
Target.create "RunTests" (fun _ ->
run dotnet [ "build" ] sharedTestsPath
[
"server", dotnet [ "watch"; "run" ] serverTestsPath
"mocha", npm [ "test" ] clientTestsPath
"client", dotnet [ "fable"; "watch"; "-o"; "output"; "-s"; "--run"; "npx"; "vite" ] clientTestsPath
]
|> runParallel)
By copying the full context of the code and test files and providing competent, human-given directions, GPT-4o (rather than Copilot) is eventually able to find the fix. See https://chatgpt.com/share/45bf6f26-85a3-463f-9a57-ce4476afc82a
@giuliohome thanks for your contribution, it has been merged and released. We'd like to keep the discussion #615 going to determine whether we'd like this to be the final solution, or make the demo app slightly more resilient by making sure the "add todo" operation can work even if loading the todos somehow failed.
Fix bug issue #615
Helping Copilot to explain the fix, ex-post.
Now in my words.
The issue arises because the
init
function generates a model with todos that have not started yet. As a result, the remotemap
used for theLength
assertion doesn't map to any function, causing the test to fail.