From 7c3682b4a7cb4dc55f816724af06937424e5bd47 Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 23 May 2025 12:27:08 -0400 Subject: [PATCH 1/2] temp --- .github/workflows/ci.yml | 7 +++++++ .gitignore | 4 +++- .yarnrc.yml | 4 ++++ __tests__/MSW__Http_test.res | 21 ++++++++++++++------- vitest.config.mjs | 22 +++++++++++++--------- 5 files changed, 41 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e3c0c42..98e16fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,13 @@ jobs: - run: yarn run format:ci - run: yarn run build:ci - run: yarn run test:ci + - uses: mikepenz/action-junit-report@v5 + if: github.event_name == 'pull_request' && (success() || failure()) + with: + check_name: 'Test Results' + fail_on_failure: true + report_paths: | + **/test-results/**/*.xml - uses: actions/cache/save@v4 with: key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.gitignore b/.gitignore index 973d266..fa40acb 100644 --- a/.gitignore +++ b/.gitignore @@ -137,4 +137,6 @@ lib .merlin .graphql_ppx_cache .bsb.lock -*.res.js \ No newline at end of file +*.res.js + +test-results/junit.xml \ No newline at end of file diff --git a/.yarnrc.yml b/.yarnrc.yml index 74cbf0b..7477efc 100644 --- a/.yarnrc.yml +++ b/.yarnrc.yml @@ -1,5 +1,9 @@ compressionLevel: mixed +enableGlobalCache: false + +cacheFolder: ./.yarn/cache + enableMessageNames: false nodeLinker: node-modules diff --git a/__tests__/MSW__Http_test.res b/__tests__/MSW__Http_test.res index 9f63506..0f67f45 100644 --- a/__tests__/MSW__Http_test.res +++ b/__tests__/MSW__Http_test.res @@ -43,6 +43,7 @@ describe("MSW__Http", () => { testAsync( "should return data for a response", async t => { + let expect = expect(t, ...) let value = { history: [{openingPrice: 1, closingPrice: 2}, {openingPrice: 2, closingPrice: 8}], } @@ -61,7 +62,7 @@ describe("MSW__Http", () => { JsonCombinators.Json.decode(json, Decode.stockPrice) ->Result.getExn - ->(expect(t, _)) + ->expect ->Expect.toEqual(value) }, ) @@ -71,6 +72,7 @@ describe("MSW__Http", () => { testAsync( "should return data for a response", async t => { + let expect = expect(t, ...) let value = { history: [{openingPrice: 1, closingPrice: 2}, {openingPrice: 2, closingPrice: 8}], } @@ -89,7 +91,7 @@ describe("MSW__Http", () => { json ->JsonCombinators.Json.decode(Decode.stockPrice) ->Result.getExn - ->(expect(t, _)) + ->expect ->Expect.toEqual(value) }, ) @@ -99,6 +101,7 @@ describe("MSW__Http", () => { testAsync( "should return data for a response", async t => { + let expect = expect(t, ...) let value = { history: [{openingPrice: 1, closingPrice: 2}, {openingPrice: 2, closingPrice: 8}], } @@ -117,7 +120,7 @@ describe("MSW__Http", () => { json ->JsonCombinators.Json.decode(Decode.stockPrice) ->Result.getExn - ->(expect(t, _)) + ->expect ->Expect.toEqual(value) }, ) @@ -127,6 +130,7 @@ describe("MSW__Http", () => { testAsync( "should return data for a response", async t => { + let expect = expect(t, ...) let value = { history: [{openingPrice: 1, closingPrice: 2}, {openingPrice: 2, closingPrice: 8}], } @@ -145,7 +149,7 @@ describe("MSW__Http", () => { json ->JsonCombinators.Json.decode(Decode.stockPrice) ->Result.getExn - ->(expect(t, _)) + ->expect ->Expect.toEqual(value) }, ) @@ -155,6 +159,7 @@ describe("MSW__Http", () => { testAsync( "should return data for a response", async t => { + let expect = expect(t, ...) MSWServerInstance.server->Server.use( Http.delete( #URL(url), @@ -165,7 +170,7 @@ describe("MSW__Http", () => { ) let response = await Fetch.fetch(url, {method: #DELETE}) - response->Fetch.Response.statusText->(expect(t, _))->Expect.toEqual("No Content") + response->Fetch.Response.statusText->expect->Expect.toEqual("No Content") }, ) }) @@ -174,6 +179,7 @@ describe("MSW__Http", () => { testAsync( "should return data for a response", async t => { + let expect = expect(t, ...) MSWServerInstance.server->Server.use( Http.options( #URL(url), @@ -184,7 +190,7 @@ describe("MSW__Http", () => { ) let response = await Fetch.fetch(url, {method: #OPTIONS}) - response->Fetch.Response.statusText->(expect(t, _))->Expect.toEqual("No Content") + response->Fetch.Response.statusText->expect->Expect.toEqual("No Content") }, ) }) @@ -193,6 +199,7 @@ describe("MSW__Http", () => { testAsync( "should return error for networkError", async t => { + let expect = expect(t, ...) MSWServerInstance.server->Server.use( Http.get(#URL(url), async _options => Http.Response.error()), ) @@ -208,7 +215,7 @@ describe("MSW__Http", () => { let error = Option.getExn(result) let name = Js.Exn.name(error)->Option.getExn let message = Js.Exn.message(error)->Option.getExn - expect(t, (name, message))->Expect.toEqual(("TypeError", "Failed to fetch")) + (name, message)->expect->Expect.not->Expect.toEqual(("TypeError", "Failed to fetch")) }, ) }) diff --git a/vitest.config.mjs b/vitest.config.mjs index 973af34..8bdc0ee 100644 --- a/vitest.config.mjs +++ b/vitest.config.mjs @@ -1,20 +1,24 @@ /// +import path from "node:path"; import { defineConfig } from "vitest/config"; -import createReScriptPlugin from '@jihchi/vite-plugin-rescript'; +import createReScriptPlugin from "@jihchi/vite-plugin-rescript"; export default defineConfig({ - plugins: [ - createReScriptPlugin({ silent: true }), - ], + plugins: [createReScriptPlugin({ silent: true })], test: { - include: ['__tests__/*_test.res.js'], - setupFiles: 'testUtils/setupTests.res.js', + include: [path.resolve("__tests__", "*_test.res.js")], + setupFiles: path.resolve("testUtils", "setupTests.res.js"), server: { deps: { fallbackCJS: true, }, }, - reporters: process.env.GITHUB_ACTIONS ? ['verbose', 'github-actions'] : ['default'], + reporters: process.env.GITHUB_ACTIONS + ? ["verbose", "github-actions", "junit"] + : ["default"], + outputFile: { + junit: path.resolve("test-results", "junit.xml"), + }, deps: { optimizer: { ssr: { @@ -25,5 +29,5 @@ export default defineConfig({ }, }, }, - } -}); \ No newline at end of file + }, +}); From 1bbce739f45ac4e989c2e29a7545f94b9de2c119 Mon Sep 17 00:00:00 2001 From: Rob Date: Fri, 23 May 2025 12:29:28 -0400 Subject: [PATCH 2/2] test --- __tests__/MSW__Http_test.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__tests__/MSW__Http_test.res b/__tests__/MSW__Http_test.res index 0f67f45..3e204a3 100644 --- a/__tests__/MSW__Http_test.res +++ b/__tests__/MSW__Http_test.res @@ -215,7 +215,7 @@ describe("MSW__Http", () => { let error = Option.getExn(result) let name = Js.Exn.name(error)->Option.getExn let message = Js.Exn.message(error)->Option.getExn - (name, message)->expect->Expect.not->Expect.toEqual(("TypeError", "Failed to fetch")) + (name, message)->expect->Expect.toEqual(("TypeError", "Failed to fetch")) }, ) })