Skip to content

Commit cb90885

Browse files
committed
readme: test
1 parent f2789ca commit cb90885

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

README.md

+30-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Build and test status](https://github.com/metachris/typescript-boilerplate/workflows/Lint%20and%20test/badge.svg)](https://github.com/metachris/micropython-ctl/actions?query=workflow%3A%22Build+and+test%22)
44

5-
TypeScript project boilerplate with modern tooling, for Node.js and browser. Get started quickly and right-footed 🚀
5+
TypeScript project boilerplate with modern tooling, for Node.js programs, libraries and browser modules. Get started quickly and right-footed 🚀
66

77
* [TypeScript 4](https://www.typescriptlang.org/)
88
* Optionally [esbuild](https://esbuild.github.io/) to bundle for browsers (and Node.js)
@@ -61,19 +61,44 @@ You can generate a full build with both `tsc` and `esbuild` with `yarn build-all
6161
* `esbuild` has a `--global-name=xyz` flag, to store the exports from the entry point in a global variable. See also the [esbuild "Global name" docs](https://esbuild.github.io/api/#global-name).
6262
* Read more about the esbuild setup [here](https://www.metachris.com/2021/04/starting-a-typescript-project-in-2021/#esbuild).
6363

64+
65+
## Tests with Jest
66+
67+
You can write [Jest tests](https://jestjs.io/docs/getting-started) [like this](https://github.com/metachris/typescript-boilerplate/blob/master/src/main.test.ts):
68+
69+
```typescript
70+
import { greet } from './main'
71+
72+
test('the data is peanut butter', () => {
73+
expect(1).toBe(1)
74+
});
75+
76+
test('greeting', () => {
77+
expect(greet('Foo')).toBe('Hello Foo')
78+
});
79+
```
80+
81+
Run the tests with `yarn test`, no separate compile step is necessary.
82+
83+
* See also the [Jest documentation](https://jestjs.io/docs/getting-started).
84+
* The tests can be automatically run in CI (GitHub Actions, GitLab CI): [`.github/workflows/lint-and-test.yml`](https://github.com/metachris/typescript-boilerplate/blob/master/.github/workflows/lint-and-test.yml), [`.gitlab-ci.yml`](https://github.com/metachris/typescript-boilerplate/blob/master/.gitlab-ci.yml)
85+
86+
6487
## Documentation, published with CI
6588

66-
You can auto-generate API documentation from the TyoeScript source files using [TypeDoc](https://typedoc.org/guides/doccomments/). The generated documentation can be published to GitHub / GitLab pages through the CI:
89+
You can auto-generate API documentation from the TyoeScript source files using [TypeDoc](https://typedoc.org/guides/doccomments/). The generated documentation can be published to GitHub / GitLab pages through the CI.
90+
91+
Generate the documentation, using `src/main.ts` as entrypoint (configured in package.json):
6792

6893
```bash
6994
yarn docs
7095
```
7196

72-
The resulting HTML is saved in `docs/`. It uses `src/main.ts` as entrypoint (configured in package.json).
97+
The resulting HTML is saved in `docs/`.
7398

7499
You can publish the documentation through CI:
75-
* [GitHub pages](https://pages.github.com/): uncomment content of `.github/workflows/deploy-gh-pages.yml` and enable pages in GitHub repo settings
76-
* [GitLab pages](https://docs.gitlab.com/ee/user/project/pages/): uncomment deploy task in `.gitlab-ci.yml`
100+
* [GitHub pages](https://pages.github.com/): See [`.github/workflows/deploy-gh-pages.yml`](https://github.com/metachris/typescript-boilerplate/blob/master/.github/workflows/deploy-gh-pages.yml)
101+
* [GitLab pages](https://docs.gitlab.com/ee/user/project/pages/): [`.gitlab-ci.yml`](https://github.com/metachris/typescript-boilerplate/blob/master/.gitlab-ci.yml)
77102

78103
This is the documentation for this boilerplate project: https://metachris.github.io/typescript-boilerplate/
79104

0 commit comments

Comments
 (0)