Skip to content

Commit f51cd62

Browse files
authored
test(e2e): reconfigure e2e test config and structure (#3043)
1 parent 8d0ef1f commit f51cd62

File tree

387 files changed

+20918
-41155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+20918
-41155
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
dist/
22
node_modules/
3-
e2e/
43
coverage/
54
website/src/**/*.js
65
presets/index.d.ts

.github/workflows/ci.yml

Lines changed: 26 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,48 @@ jobs:
1717
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1818
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
1919

20-
lint-and-typecheck:
21-
name: Running build and lint
20+
prepare-npm-cache:
2221
runs-on: ubuntu-latest
2322

2423
steps:
25-
- uses: actions/checkout@v2
26-
- name: Get npm cache
27-
id: npm-cache
28-
run: echo "::set-output name=dir::$(npm config get cacheFolder)"
29-
- uses: actions/cache@v2
24+
- uses: actions/[email protected]
25+
- uses: actions/[email protected]
3026
with:
31-
path: ${{ steps.npm-cache.outputs.dir }}
32-
key: ubuntu-latest-node-12.x-npm-${{ hashFiles('**/package-lock.json') }}
33-
restore-keys: |
34-
ubuntu-latest-node-12.x-npm-
27+
node-version: 16.x
28+
cache: npm
29+
- name: Validate cache
30+
run: npm ci
31+
32+
lint-and-typecheck:
33+
name: build-lint
34+
runs-on: ubuntu-latest
35+
needs: prepare-npm-cache
36+
37+
steps:
38+
- uses: actions/[email protected]
3539
- uses: actions/[email protected]
3640
with:
37-
node-version: 12.x
38-
- name: Install and build
41+
node-version: 16.x
42+
cache: npm
43+
- name: Install
3944
run: npm ci
4045
- name: Run eslint
4146
run: npm run lint
4247
- name: Run prettier
43-
run: npm run lint:prettier-ci
48+
run: npm run lint-prettier-ci
4449

45-
test-ubuntu:
50+
test:
4651
name: Node v${{ matrix.node-version }} on ${{ matrix.os }}
4752
strategy:
4853
fail-fast: false
4954
matrix:
50-
node-version: [10.x, 12.x, 14.x]
51-
os: [ubuntu-latest]
55+
node-version: [10.x, 12.x, 14.x, 16.x]
56+
os: [ubuntu-latest, windows-latest]
5257
runs-on: ${{ matrix.os }}
58+
needs: prepare-npm-cache
5359

5460
steps:
55-
- uses: actions/checkout@v2
61+
- uses: actions/checkout@v2.4.0
5662
- name: Get npm cache
5763
id: npm-cache
5864
run: echo "::set-output name=dir::$(npm config get cacheFolder)"
@@ -69,11 +75,7 @@ jobs:
6975
- name: Install and build
7076
run: npm ci
7177
- name: Run tests with coverage
72-
run: npm run test -- --coverage && cat ./coverage/lcov.info
73-
env:
74-
CI: true
75-
- name: Run real repo tests
76-
run: npm run test:external-repos
78+
run: npm run test-ci -- --coverage && cat ./coverage/lcov.info
7779
env:
7880
CI: true
7981
- name: Coveralls parallel
@@ -83,47 +85,8 @@ jobs:
8385
flag-name: run-${{ matrix.node-version }}
8486
parallel: true
8587

86-
test-windows:
87-
name: Node v${{ matrix.node-version }} on ${{ matrix.os }}
88-
strategy:
89-
fail-fast: false
90-
matrix:
91-
node-version: [10.x, 12.x, 14.x]
92-
os: [windows-latest]
93-
runs-on: ${{ matrix.os }}
94-
95-
steps:
96-
- name: Set git config
97-
shell: bash
98-
run: |
99-
git config --global core.autocrlf false
100-
git config --global core.symlinks true
101-
if: runner.os == 'Windows'
102-
- uses: actions/checkout@v2
103-
- name: Get npm cache
104-
id: npm-cache
105-
run: echo "::set-output name=dir::$(npm config get cacheFolder)"
106-
- uses: actions/cache@v2
107-
with:
108-
path: ${{ steps.npm-cache.outputs.dir }}
109-
key: ${{ runner.os }}-node-${{ matrix.node-version }}-npm-${{ hashFiles('**/package-lock.json') }}
110-
restore-keys: |
111-
${{ runner.os }}-node-${{ matrix.node-version }}-npm-
112-
- name: Use Node.js ${{ matrix.node-version }}
113-
uses: actions/[email protected]
114-
with:
115-
node-version: ${{ matrix.node-version }}
116-
- name: Install and build
117-
run: npm ci
118-
- name: run unit tests
119-
run: npm run test:unit
120-
- name: run real project tests
121-
run: npm run test:external-repos
122-
env:
123-
CI: true
124-
12588
finish:
126-
needs: test-ubuntu
89+
needs: test
12790
runs-on: ubuntu-latest
12891
steps:
12992
- name: Coveralls finished

.prettierignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
dist/
2-
e2e/
3-
!e2e/__helpers__
4-
!e2e/__serializers__
5-
!e2e/__tests__
62
node_modules/
73
src/**/__snapshots__/
4+
e2e/__tests__/__snapshots__/

CONTRIBUTING.md

Lines changed: 95 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,120 @@
11
# Contributing
22

3-
When contributing to this repository, please first discuss the change you wish to make via [slack](https://bit.ly/3bRHFPQ) or [issue](https://github.com/kulshekhar/ts-jest/issues) with the owners of this repository before making a change.
3+
When 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)
5+
with the owners of this repository before making a change.
46

57
Please note we have a code of conduct, please follow it in all your interactions with the project.
68

7-
## Pull Request Process
9+
## Workflow and Pull Requests
810

9-
1. Ensure the tests are passing and that you have latest `master` branch merged in.
10-
2. Update the `docs/` with details of your changes if required.
11-
3. If possible, squash your commits. There must be only one commit in your PR (until a review). Then after each review requesting changes, DO NOT squash your commits with the one before the review, so that we can see intermediate modifications.
12-
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you do not have permission to do that, you may request the second reviewer to merge it for you.
11+
The team will monitor pull requests. We'll do our best to provide updates and feedback throughout the process.
1312

14-
## Code of Conduct
13+
_Before_ submitting a pull request, please make sure the following is done…
1514

16-
### Our Pledge
15+
1. 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/
1716

18-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
17+
Open terminal (e.g. Terminal, iTerm, Git Bash or Git Shell) and type:
1918

20-
### Our Standards
19+
```sh-session
20+
$ git clone https://github.com/<your_username>/ts-jest
21+
$ cd ts-jest
22+
$ git checkout -b my_branch
23+
```
2124

22-
Examples of behavior that contributes to creating a positive environment include:
25+
Note: Replace `<your_username>` with your GitHub username
2326

24-
- Using welcoming and inclusive language
25-
- Being respectful of differing viewpoints and experiences
26-
- Gracefully accepting constructive criticism
27-
- Focusing on what is best for the community
28-
- Showing empathy towards other community members
27+
2. `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).
2928

30-
Examples of unacceptable behavior by participants include:
29+
3. Make sure you have a compatible version of `node` installed (As of April 14th 2021, `v14.x` is recommended).
3130

32-
- The use of sexualized language or imagery and unwelcome sexual attention or advances
33-
- Trolling, insulting/derogatory comments, and personal or political attacks
34-
- Public or private harassment
35-
- Publishing others' private information, such as a physical or electronic address, without explicit permission
36-
- Other conduct which could reasonably be considered inappropriate in a professional setting
31+
```sh
32+
node -v
33+
```
3734

38-
### Our Responsibilities
35+
4. Run `npm ci`. `ts-jest` will automatically build source files into `dist/` after installing dependencies.
3936

40-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
37+
5. Ensure the test suite passes via `npm run test`.
4138

42-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
39+
### Testing
4340

44-
### Scope
41+
Code that is written needs to be tested to ensure that it achieves the desired behaviour. Tests either fall into a unit
42+
test or an integration test.
4543

46-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
44+
##### Unit tests
4745

48-
### Enforcement
46+
The unit test files are associated with source files which are in `src/`. If the scope of your work only requires a unit test,
47+
this is where you will write it in. Tests here usually don't require much if any setup.
4948

50-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
51-
reported by contacting the project team at [email protected]. All
52-
complaints will be reviewed and investigated and will result in a response that
53-
is deemed necessary and appropriate to the circumstances. The project team is
54-
obligated to maintain confidentiality with regard to the reporter of an incident.
55-
Further details of specific enforcement policies may be posted separately.
49+
##### Integration tests
5650

57-
Project maintainers who do not follow or enforce the Code of Conduct in good
58-
faith may face temporary or permanent repercussions as determined by other
59-
members of the project's leadership.
51+
There will be situations however where the work you have done cannot be tested alone using unit tests. In situations like this,
52+
you should write an integration test for your code. The integration tests reside within the `e2e` directory.
53+
Within this directory, there is a `__tests__` directory. This is where you will write the integration test itself.
54+
The tests within this directory execute jest itself using `run-jest.ts` and assertions are usually made on one if not all
55+
the output of the following `status`, `stdout` and `stderr`. The other subdirectories within the `e2e` directory are
56+
where you will write the files that jest will run for your integration tests. Feel free to take a look at any of the tests
57+
in the `__tests__` directory within `e2e` to have a better sense of how it is currently being done.
6058

61-
### Attribution
59+
It is possible to run the integration test itself manually to inspect that the new behaviour is indeed correct.
60+
Here is a small code snippet of how to do just that. This is useful when debugging a failing test.
6261

63-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
64-
available at [http://contributor-covenant.org/version/1/4][version]
62+
```bash
63+
$ cd e2e/test-utils
64+
$ node ../../node_modules/jest/bin/jest.js # It is possible to use node --inspect or ndb
65+
PASS __tests__/test-utils.spec.ts
66+
✓ stub (3ms)
6567

66-
[homepage]: http://contributor-covenant.org
67-
[version]: http://contributor-covenant.org/version/1/4/
68+
Test Suites: 1 passed, 1 total
69+
Tests: 1 passed, 1 total
70+
Snapshots: 0 total
71+
Time: 0.232 s, estimated 1 s
72+
Ran all test suites.
73+
```
74+
75+
### Additional Workflow for any changes made to website or docs
76+
77+
If you are making changes to the website or documentation, test the `website` folder and run the server to check if your
78+
changes are being displayed accurately.
79+
80+
1. Locate to the `website` directory and install any website specific dependencies by typing in `npm ci`.
81+
2. 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+
```
87+
3. 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+
89+
The `ts-jest` website also offers documentation for older versions of `ts-jest`, which you can edit in `website/versioned_docs`.
90+
After making changes to the current documentation in `docs`, please check if any older versions of the documentation
91+
have 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+
97+
We 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
98+
have 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+
102+
The 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+
120+
By contributing to `ts-jest`, you agree that your contributions will be licensed under its MIT license.

0 commit comments

Comments
 (0)