Skip to content

feat(unit-test): introduce unit test on website redesign branch (#5178 #5178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ node_modules
public/en/user-survey-report
public/static/documents
public/static/legacy

# These should be fixed in the future as the
# tests and scripts will be updated in this PR
tests
coverage

# MDX Plugin enforces Prettier formatting which should
# be done in the future as we don't want to update the Markdown file
Expand Down
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
"extends": ["plugin:prettier/recommended"],
"env": { "node": true, "es6": true }
},
{
"files": [
"**/**.test.{js,jsx,ts,tsx}"
],
"extends": ["plugin:testing-library/react"],
"env": { "jest": true, "node": true, "browser": true }
},
{
"files": ["**/*.{ts,tsx}"],
"globals": { "globalThis": false }
Expand Down
27 changes: 27 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
Please read the [Code of Conduct](https://github.com/nodejs/nodejs.org/blob/main/CODE_OF_CONDUCT.md) and the [Contributing Guidelines](https://github.com/nodejs/nodejs.org/blob/main/CONTRIBUTING.md) before opening a pull request.
-->

## Description

<!-- Write a brief description of the changes introduced by this PR -->

## Related Issues

<!--
Link to the issue that is fixed by this PR (if there is one)
e.g. Fixes #1234, Addresses #1234, Related to #1234, etc.
-->

### Check List

<!--
ATTENTION
Please follow this check list to ensure that you've followed all items before opening this PR
-->

- [ ] I have read the [Contributing Guidelines](https://github.com/nodejs/nodejs.org/blob/main/CONTRIBUTING.md) and made commit messages that follow the guideline.
- [ ] I have run `lint` to ensure the code follows the style guide. And run `npm run lint:fix` to fix the style errors if necessary.
- [ ] I have run `npm run format` to ensure the code follows the style guide.
- [ ] I have run `npm run test` to check if all tests are passing, and/or `npm run test -- -u` to update snapshots if I created and/or updated React Components.
- [ ] I've covered new added functionality with unit tests if necessary.
2 changes: 1 addition & 1 deletion .github/workflows/github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
25 changes: 25 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,31 @@ jobs:
- name: Run Linting
run: npm run lint

unit-tests:
name: Tests on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Git Checkout
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: npm

- name: Install NPM packages
run: npm ci

- name: Run Unit Tests
run: npm run test-ci

build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ pages/en/blog/year-[0-9][0-9][0-9][0-9].md
# ESLint Cache Files
.eslintjscache
.eslintmdcache

# Jest
coverage
.swc
4 changes: 1 addition & 3 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ node_modules
public/en/user-survey-report
public/static/documents
public/static/legacy

# These should be fixed in the future as the
# tests and scripts will be updated in this PR
tests
coverage

# MDX Plugin enforces Prettier formatting which should
# be done in the future as we don't want to update the Markdown file
Expand Down
6 changes: 3 additions & 3 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit_message: "chore(i18n): added new translations from crowdin"
pull_request_title: "chore(i18n): crowdin sync"
pull_request_labels:
commit_message: 'chore(i18n): added new translations from crowdin'
pull_request_title: 'chore(i18n): crowdin sync'
pull_request_labels:
- i18n
- crowdin
files:
Expand Down
13 changes: 13 additions & 0 deletions jest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import nextJest from 'next/jest.js';

const createJestConfig = nextJest({
dir: './',
});

/** @type {import('jest').Config} */
const customJestConfig = {
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
};

export default createJestConfig(customJestConfig);
Loading