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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ lib
.merlin
.graphql_ppx_cache
.bsb.lock
*.res.js
*.res.js

test-results/junit.xml
4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
compressionLevel: mixed

enableGlobalCache: false

cacheFolder: ./.yarn/cache

enableMessageNames: false

nodeLinker: node-modules
21 changes: 14 additions & 7 deletions __tests__/MSW__Http_test.res
Original file line number Diff line number Diff line change
Expand Up @@ -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}],
}
Expand All @@ -61,7 +62,7 @@ describe("MSW__Http", () => {

JsonCombinators.Json.decode(json, Decode.stockPrice)
->Result.getExn
->(expect(t, _))
->expect
->Expect.toEqual(value)
},
)
Expand All @@ -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}],
}
Expand All @@ -89,7 +91,7 @@ describe("MSW__Http", () => {
json
->JsonCombinators.Json.decode(Decode.stockPrice)
->Result.getExn
->(expect(t, _))
->expect
->Expect.toEqual(value)
},
)
Expand All @@ -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}],
}
Expand All @@ -117,7 +120,7 @@ describe("MSW__Http", () => {
json
->JsonCombinators.Json.decode(Decode.stockPrice)
->Result.getExn
->(expect(t, _))
->expect
->Expect.toEqual(value)
},
)
Expand All @@ -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}],
}
Expand All @@ -145,7 +149,7 @@ describe("MSW__Http", () => {
json
->JsonCombinators.Json.decode(Decode.stockPrice)
->Result.getExn
->(expect(t, _))
->expect
->Expect.toEqual(value)
},
)
Expand All @@ -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),
Expand All @@ -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")
},
)
})
Expand All @@ -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),
Expand All @@ -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")
},
)
})
Expand All @@ -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()),
)
Expand All @@ -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.toEqual(("TypeError", "Failed to fetch"))
},
)
})
Expand Down
22 changes: 13 additions & 9 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
/// <reference types="vitest" />
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: {
Expand All @@ -25,5 +29,5 @@ export default defineConfig({
},
},
},
}
});
},
});