Skip to content
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

Add Jest framework for unit testing and first Jest test #90

Closed
wants to merge 4 commits into from
Closed
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
24 changes: 24 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"include": [
"es6.promise",
"es7.promise.finally"
],
"corejs": "2.0",
"debug": true
}
],
[
"@babel/preset-react",
{
"targets": {
"node": "current"
}
}
]
]
}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
# misc
.DS_Store
*.pem
.project
.settings/

# debug
npm-debug.log*
Expand All @@ -40,4 +42,7 @@ next-env.d.ts

# Cypress file
cypress/screenshots/
cypress/videos/
cypress/videos/

#snapshots
__snapshots__/
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,21 @@ Check out our [Next.js deployment documentation](https://nextjs.org/docs/deploym
2. Update cypress/config/cypress.config.dev.ts with credentials- When login functionality is implemented. Not needed now.
3. Run npm run test which will open cypress window -> choose E2E testing -> Choose browser to run the tests against -> choose test files to run. This will use dev config file.
4. Running test through cmd, npm run test:dev. This will use electron headless browser to run the tests.

## Unit tests
[Jest](https://jestjs.io/) is used to write unit tests

- Run npm install

- Run all tests:

`jest`

`# or`

`npm run test:jest`


- Run the tests in a single file:

`jest path/to/my-test.js`
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [['@babel/preset-env', {targets: {node: 'current'}}],
'@babel/preset-typescript',
]
};
6 changes: 6 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('jest').Config} */
const config = {
verbose: true,
};

module.exports = config;
Loading
Loading