-
Notifications
You must be signed in to change notification settings - Fork 151
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 test setup for monorepo and example test #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
preset: "ts-jest/presets/js-with-ts", | ||
testMatch: [ | ||
"<rootDir>/packages/*/src/**/__tests__/**/*.{js,jsx,ts,tsx}", | ||
"<rootDir>/packages/*/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}", | ||
], | ||
coveragePathIgnorePatterns: [ | ||
"/node_modules/", | ||
"dist/", | ||
"<rootDir>/packages/components/src/index.ts", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this needed if it doesn't match the spec? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is for code coverage metrics. not sure why this file was specifically excluded before, but i kept it here to not break anything historical |
||
"<rootDir>/packages/componentssrc/components/index.ts", | ||
], | ||
collectCoverageFrom: [ | ||
"<rootDir>/packages/*/src/**/*.{js,ts,tsx,jsx}", | ||
"!<rootDir>/packages/*/src/**/*.stories.*", | ||
], | ||
moduleNameMapper: { | ||
"\\.s?css$": "identity-obj-proxy", | ||
}, | ||
coverageThreshold: { | ||
global: { | ||
branches: 90, | ||
functions: 90, | ||
lines: 90, | ||
statements: 90, | ||
}, | ||
}, | ||
setupFilesAfterEnv: ["<rootDir>/utils/setupTests.ts"], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,10 +18,18 @@ | |
"build:components": "yarn workspace @web3-ui/components build", | ||
"build:hooks": "yarn workspace @web3-ui/hooks build", | ||
"build": "yarn build:components && yarn build:hooks", | ||
"test": "yarn workspace @web3-ui/components test", | ||
"test": "jest", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, absolutely, that is what I was thinking about. |
||
"test:watch": "yarn test --watch", | ||
"test:coverage": "jest --coverage --colors", | ||
"storybook:components": "yarn workspace @web3-ui/components storybook", | ||
"storybook:hooks": "yarn workspace @web3-ui/hooks storybook" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/jest-dom": "^5.15.1", | ||
"@testing-library/react": "^12.1.2", | ||
"jest": "^26.6.3", | ||
"ts-jest": "^26.4.4" | ||
}, | ||
"lint-staged": { | ||
"*.{ts,tsx,json,js,jsx}": "yarn format" | ||
} | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import { Address } from './Address'; | ||
|
||
describe('Address', () => { | ||
it('renders without throwing', () => { | ||
const { container } = render(<Address value="taylorswift.eth" />); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,5 @@ | |
"target": "es5" | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": ["./src"] | ||
"include": ["./packages/*/src"] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import "@testing-library/jest-dom"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would we need to ignore dist also from within the packages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe this will ignore any instance of
dist
, although i might be wrong. we're not using the coverage stats yet though, so it probably doesn't matter?