Skip to content
Open
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
33 changes: 33 additions & 0 deletions __tests__/App_test.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
open Test
open App
open Dom

@get external textContent: Dom.element => string = "textContent"

@module("@testing-library/react")
external act: (@uncurry unit => unit) => unit = "act"

@val external window: {..} = "window"
@send external remove: Dom.element => unit = "remove"

let createContainer = () => {
let containerElement: Dom.element = window["document"]["createElement"]("div")
let _ = window["document"]["body"]["appendChild"](containerElement)
containerElement
}

let cleanupContainer = (container: Dom.element) => {
ReactDOM.unmountComponentAtNode(container)
remove(container)
}

let testWithReact = testWith(~setup=createContainer, ~teardown=cleanupContainer)
let testAsyncWithReact = testAsyncWith(~setup=createContainer, ~teardown=cleanupContainer)

testWithReact("Can render", container => {
act(() => ReactDOM.render(<App />, container))

let countElement = ReactDOM.querySelector(".count")

cleanupContainer(container)
})
11 changes: 11 additions & 0 deletions bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
{
"dir": "src",
"subdirs": true
},
{
"dir": "__tests__",
"subdirs": true,
"type": "dev"
}
],
"package-specs": [
Expand All @@ -14,6 +19,12 @@
],
"suffix": ".bs.js",
"bs-dependencies": ["@rescript/core", "@rescript/react"],
"bs-dev-dependencies": [
"rescript-test",
"@glennsl/rescript-jest",
"rescript-nodejs",
"rescript-js"
],
"jsx": {
"version": 4,
"mode": "automatic"
Expand Down
Binary file modified bun.lockb
Binary file not shown.
File renamed without changes.
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "rspack-rescript-react",
"private": true,
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "concurrently \"bun run res:dev\" \"rspack serve\"",
"build": "cross-env NODE_ENV=production rspack build",
Expand All @@ -13,7 +14,8 @@
"format:check": "biome check .",
"format:write": "biome format . --write",
"lint:check": "biome lint .",
"lint": "biome lint --apply ."
"lint": "biome lint --apply .",
"test": "retest __tests__/*.bs.js"
},
"dependencies": {
"@emotion/css": "^11.11.2",
Expand All @@ -29,17 +31,22 @@
"@commitlint/cli": "^17.7.2",
"@commitlint/config-conventional": "^17.7.0",
"@commitlint/cz-commitlint": "^17.7.2",
"@glennsl/rescript-jest": "^0.10.0",
"@rspack/cli": "latest",
"@rspack/core": "^0.3.6",
"@rspack/plugin-react-refresh": "^0.3.6",
"@svgr/webpack": "^8.1.0",
"@testing-library/react": "^14.0.0",
"@types/react": "18.2.0",
"@types/react-dom": "18.2.1",
"commitizen": "^4.3.0",
"concurrently": "^8.2.1",
"cross-env": "^7.0.3",
"husky": "^8.0.3",
"inquirer": "^9.2.11",
"rescript-js": "^1.0.0-beta.2",
"rescript-nodejs": "^15.0.0",
"rescript-test": "^5.0.0",
"typescript": "^5.0.4",
"webpack-bundle-analyzer": "^4.9.1"
},
Expand Down
File renamed without changes.