Skip to content

Commit 0634d10

Browse files
committed
Add tests to react app
1 parent c1cd82e commit 0634d10

7 files changed

+425
-42
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.pnp.js
88

99
# testing
10-
/coverage
10+
coverage
1111

1212
# production
1313
/build

web/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,18 @@ To update a specific dependency to a specific/latest version:
5151
> cd web
5252
> npm install react@latest
5353
```
54+
55+
### Testing
56+
57+
To execute the tests:
58+
```sh
59+
> cd web
60+
> npm run test -- --watchAll=false
61+
```
62+
63+
To view the coverage report:
64+
```sh
65+
> cd web
66+
> npm run test -- --watchAll=false --coverage
67+
```
68+

web/build.gradle

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ gitPublish {
1818
include '**.js'
1919
include '**.json'
2020
include '**.html'
21-
exclude "dist/*.tar"
21+
exclude 'dist/*.tar'
22+
exclude '__test__/**'
2223
}
2324
from("${buildDir}/favicons") {
2425
into 'favicons'
@@ -63,6 +64,11 @@ task build(type: NpmTask, dependsOn:['clean', 'install']) {
6364
environment = [REACT_APP_UPDATED_AT: new Date().format('EEEEE, MMMM dd, yyyy')]
6465
}
6566

67+
task test(type: NpmTask, dependsOn:['clean', 'install']) {
68+
npmCommand = ['run-script']
69+
args = ['test', '--', '--watchAll=false']
70+
}
71+
6672
task clean(type: Delete) {
6773
delete buildDir
6874
}
@@ -71,10 +77,12 @@ task archive(type: Tar, dependsOn:['build']) {
7177
archiveBaseName = project.name
7278
destinationDirectory = file("${buildDir}/dist")
7379
from ("$buildDir") {
74-
exclude "dist/*.tar"
80+
exclude 'dist/*.tar'
81+
exclude '__test__/**'
7582
}
7683
}
7784

7885
project.tasks.build.finalizedBy([project.tasks.archive])
86+
project.tasks.build.dependsOn([project.tasks.test])
7987
project.tasks.publish.dependsOn([project.tasks.build, project.tasks.gitPublishPush])
8088
project.tasks.gitPublishPush.outputs.upToDateWhen { false }

0 commit comments

Comments
 (0)