|
2 | 2 |
|
3 | 3 | [](https://github.com/metachris/micropython-ctl/actions?query=workflow%3A%22Build+and+test%22)
|
4 | 4 |
|
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 🚀 |
6 | 6 |
|
7 | 7 | * [TypeScript 4](https://www.typescriptlang.org/)
|
8 | 8 | * 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
|
61 | 61 | * `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).
|
62 | 62 | * Read more about the esbuild setup [here](https://www.metachris.com/2021/04/starting-a-typescript-project-in-2021/#esbuild).
|
63 | 63 |
|
| 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 | + |
64 | 87 | ## Documentation, published with CI
|
65 | 88 |
|
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): |
67 | 92 |
|
68 | 93 | ```bash
|
69 | 94 | yarn docs
|
70 | 95 | ```
|
71 | 96 |
|
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/`. |
73 | 98 |
|
74 | 99 | 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) |
77 | 102 |
|
78 | 103 | This is the documentation for this boilerplate project: https://metachris.github.io/typescript-boilerplate/
|
79 | 104 |
|
|
0 commit comments