UNPKG

5.29 kBMarkdownView Raw
1# Contributing
2
3When contributing to this repository, please first discuss the change you wish to make via
4[discussion](https://github.com/kulshekhar/ts-jest/discussions) or [issue](https://github.com/kulshekhar/ts-jest/issues)
5with the owners of this repository before making a change.
6
7Please note we have a code of conduct, please follow it in all your interactions with the project.
8
9## Workflow and Pull Requests
10
11The team will monitor pull requests. We'll do our best to provide updates and feedback throughout the process.
12
13_Before_ submitting a pull request, please make sure the following is done…
14
151. Fork the repo and create your branch from `main`. A guide on how to fork a repository: https://help.github.com/articles/fork-a-repo/
16
17 Open terminal (e.g. Terminal, iTerm, Git Bash or Git Shell) and type:
18
19 ```sh-session
20 $ git clone https://github.com/<your_username>/ts-jest
21 $ cd ts-jest
22 $ git checkout -b my_branch
23 ```
24
25 Note: Replace `<your_username>` with your GitHub username
26
272. `ts-jest` uses `npm` for running development scripts. If you haven't already done so, please [install npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
28
293. Make sure you have a compatible version of `node` installed (As of April 14th 2021, `v14.x` is recommended).
30
31 ```sh
32 node -v
33 ```
34
354. Run `npm ci`. `ts-jest` will automatically build source files into `dist/` after installing dependencies.
36
375. Ensure the test suite passes via `npm run test`.
38
39### Testing
40
41Code that is written needs to be tested to ensure that it achieves the desired behaviour. Tests either fall into a unit
42test or an integration test.
43
44##### Unit tests
45
46The unit test files are associated with source files which are in `src/`. If the scope of your work only requires a unit test,
47this is where you will write it in. Tests here usually don't require much if any setup.
48
49##### Integration tests
50
51There will be situations however where the work you have done cannot be tested alone using unit tests. In situations like this,
52you should write an integration test for your code. The integration tests reside within the `e2e` directory.
53Within this directory, there is a `__tests__` directory. This is where you will write the integration test itself.
54The tests within this directory execute jest itself using `run-jest.ts` and assertions are usually made on one if not all
55the output of the following `status`, `stdout` and `stderr`. The other subdirectories within the `e2e` directory are
56where you will write the files that jest will run for your integration tests. Feel free to take a look at any of the tests
57in the `__tests__` directory within `e2e` to have a better sense of how it is currently being done.
58
59It is possible to run the integration test itself manually to inspect that the new behaviour is indeed correct.
60Here is a small code snippet of how to do just that. This is useful when debugging a failing test.
61
62```bash
63$ cd e2e/test-utils
64$ node ../../node_modules/jest/bin/jest.js # It is possible to use node --inspect or ndb
65PASS __tests__/test-utils.spec.ts
66✓ stub (3ms)
67
68Test Suites: 1 passed, 1 total
69Tests: 1 passed, 1 total
70Snapshots: 0 total
71Time: 0.232 s, estimated 1 s
72Ran all test suites.
73```
74
75### Additional Workflow for any changes made to website or docs
76
77If you are making changes to the website or documentation, test the `website` folder and run the server to check if your
78changes are being displayed accurately.
79
801. Locate to the `website` directory and install any website specific dependencies by typing in `npm ci`.
812. Following steps are to be followed for this purpose from the root directory.
82 ```sh-session
83 $ cd website # Only needed if you are not already in the website directory
84 $ npm ci
85 $ npm run start
86 ```
873. You can run a development server to check if the changes you made are being displayed accurately by running `npm run start` in the website directory.
88
89The `ts-jest` website also offers documentation for older versions of `ts-jest`, which you can edit in `website/versioned_docs`.
90After making changes to the current documentation in `docs`, please check if any older versions of the documentation
91have a copy of the file where the change is also relevant and apply the changes to the `versioned_docs` as well.
92
93## Bugs
94
95### Where to Find Known Issues
96
97We will be using GitHub Issues for our public bugs. We will keep a close eye on this and try to make it clear when we
98have an internal fix in progress. Before filing a new issue, try to make sure your problem doesn't already exist.
99
100### Reporting New Issues
101
102The best way to get your bug fixed is to provide a reduced test case. Please provide a public repository with a runnable example.
103
104## How to Get in Touch
105
106[`#testing` on Reactiflux](https://discord.gg/j6FKKQQrW9) or [our GitHub discussion](https://github.com/kulshekhar/ts-jest/discussions)
107
108## Code Conventions
109
110- 2 spaces for indentation (no tabs).
111- 120 character line length strongly preferred.
112- Prefer `'` over `"`.
113- ES6 syntax when possible.
114- Use [TypeScript](https://www.typescriptlang.org/).
115- No semicolon (`;`) required
116- Trailing commas,
117
118## License
119
120By contributing to `ts-jest`, you agree that your contributions will be licensed under its MIT license.
121
\No newline at end of file