Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit a755e01

Browse files
authored
Test real component being rendered on page (#8)
* Test real component being rendered on page * Fix tests * Remove eslintConfig from package.json - see facebook/create-react-app#649 * Use latest version of yarn * Tidy packages - reason-react is a dependency, not dev-dependency * Need to run bsb -make-world before running tests * No need to run build before test * Run clean before test * reason-scripts is dev dependency * Test if this caches ocaml building each time * Fix tests - rescript-lang/rescript#3094 * Pin version correctly and remove linking bs-platform
1 parent 7c1a60c commit a755e01

File tree

6 files changed

+424
-351
lines changed

6 files changed

+424
-351
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
language: node_js
22
node_js:
33
- 8
4+
- 10
5+
before_install:
6+
- curl -o- -L https://yarnpkg.com/install.sh | bash
7+
- export PATH="$HOME/.yarn/bin:$PATH"
48
cache:
9+
yarn: true
510
directories:
611
- node_modules
12+
- $HOME/.cache
713
script:
8-
- yarn run build
14+
- yarn clean
915
- yarn test

bsconfig.json

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
2-
"name": "reason-scripts",
3-
"sources": ["src"],
4-
"bs-dependencies": ["reason-react", "@glennsl/bs-jest", "bs-fetch"],
2+
"name": "ishakuni-frontend",
3+
"bsc-flags": ["-bs-no-version-header", "-bs-super-errors"],
4+
"sources": [
5+
{
6+
"dir": "src"
7+
},
8+
{
9+
"dir": "src/__tests__",
10+
"type": "dev"
11+
}
12+
],
513
"reason": {
614
"react-jsx": 2
715
},
@@ -10,5 +18,14 @@
1018
"module": "commonjs",
1119
"in-source": true
1220
},
21+
"bs-dependencies": [
22+
"reason-react",
23+
"bs-fetch"
24+
],
25+
"bs-dev-dependencies": [
26+
"@glennsl/bs-jest",
27+
"bs-jest-dom",
28+
"bs-react-testing-library"
29+
],
1330
"suffix": ".bs.js"
1431
}

package.json

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,28 @@
55
"dependencies": {
66
"react": "^16.3.1",
77
"react-dom": "^16.3.1",
8-
"reason-scripts": "^1.0.0"
8+
"reason-react": "^0.5.3"
99
},
1010
"scripts": {
1111
"start": "react-scripts start",
1212
"build": "react-scripts build",
13+
"pretest": "bsb -make-world",
1314
"test": "react-scripts test",
1415
"eject": "react-scripts eject",
15-
"prepare": "npm link bs-platform"
16+
"clean": "bsb -clean-world",
17+
"preclean": "rimraf lib .merlin"
1618
},
1719
"devDependencies": {
20+
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
1821
"@glennsl/bs-jest": "^0.4.4",
1922
"bs-fetch": "^0.3.0",
20-
"reason-react": "^0.5.3"
23+
"bs-jest-dom": "^1.0.0",
24+
"bs-platform": "4.0.5",
25+
"bs-react-testing-library": "^0.4.0",
26+
"jest-dom": "^2.1.0",
27+
"react-testing-library": "^5.2.0",
28+
"reason-scripts": "^1.0.0",
29+
"rimraf": "^2.6.2"
2130
},
2231
"browserslist": [
2332
">0.2%",

src/__tests__/app_test.re

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
open Jest;
2+
open JestDom;
3+
open ReactTestingLibrary;
4+
5+
describe("App on default load", () => {
6+
7+
test("shows project tagline", () => {
8+
let message = "Fantasy bets";
9+
<App message=message />
10+
|> render
11+
|> getByText(~matcher=`Str(message))
12+
|> expect
13+
|> toBeInTheDocument
14+
});
15+
});

src/app_test.re

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)