mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
fix tests, divorce enzyme where-ever possible
This commit is contained in:
parent
3c3af304f7
commit
2fb721078e
9 changed files with 106 additions and 907 deletions
|
@ -1,8 +1,4 @@
|
|||
import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
|
||||
import Enzyme from 'enzyme';
|
||||
import enableHooks from 'jest-react-hooks-shallow';
|
||||
|
||||
Enzyme.configure({ adapter: new Adapter() });
|
||||
|
||||
// pass an instance of jest to `enableHooks()`
|
||||
enableHooks(jest);
|
||||
|
|
10
package.json
10
package.json
|
@ -43,17 +43,9 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@stylelint/postcss-css-in-js": "^0.37.2",
|
||||
"@types/enzyme": "^3.10.11",
|
||||
"@types/lodash": "^4.14.178",
|
||||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.15.6",
|
||||
"husky": "^7.0.4",
|
||||
"is-ci": "^3.0.1",
|
||||
"jest": "27.4.7",
|
||||
"jest-enzyme": "^7.1.2",
|
||||
"jest-react-hooks-shallow": "^1.5.1",
|
||||
"jest-styled-components": "^7.0.8",
|
||||
"lint-staged": "^12.3.2",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"postcss-syntax": "^0.36.2",
|
||||
|
@ -64,8 +56,6 @@
|
|||
"stylelint": "^14.3.0",
|
||||
"stylelint-config-recommended": "^6.0.0",
|
||||
"stylelint-config-styled-components": "^0.1.1",
|
||||
"stylelint-processor-styled-components": "^1.10.0",
|
||||
"ts-jest": "^27.1.3",
|
||||
"typescript": "^4.5.5"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
|
|
@ -42,10 +42,14 @@
|
|||
"@types/react-dom": "^17.0.11",
|
||||
"@types/react-helmet": "^6.1.5",
|
||||
"@types/styled-components": "^5.1.21",
|
||||
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
|
||||
"babel-loader": "^8.2.3",
|
||||
"babel-plugin-styled-components": "^2.0.2",
|
||||
"change-case": "^4.1.2",
|
||||
"tslint": "^6.1.3",
|
||||
"enzyme": "^3.11.0",
|
||||
"enzyme-adapter-react-16": "^1.15.6",
|
||||
"jest": "^27.4.7",
|
||||
"jest-styled-components": "^7.0.8",
|
||||
"typescript": "^4.5.5"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
import { shallow } from 'enzyme';
|
||||
import { render } from '@testing-library/react';
|
||||
import * as React from 'react';
|
||||
import { ReactifyNewlines } from './ReactifyNewlines';
|
||||
|
||||
it('renders a correct number of divs per newlines', () => {
|
||||
const view = shallow(<ReactifyNewlines>{`1\n2\n3`}</ReactifyNewlines>);
|
||||
it('renders a correct number of divs per newlines', async () => {
|
||||
const view = render(<ReactifyNewlines>{`test\ntest\ntest`}</ReactifyNewlines>);
|
||||
|
||||
expect(view.find('div').length).toBe(3);
|
||||
const elements = await view.findAllByText('test');
|
||||
expect(elements.length).toBe(3);
|
||||
});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
module.exports = {
|
||||
name: 'web',
|
||||
preset: 'ts-jest/presets/js-with-ts',
|
||||
testEnvironment: 'jsdom',
|
||||
reporters: ['default'],
|
||||
setupFilesAfterEnv: ['jest-styled-components', '../../hack/jestSetup.ts'],
|
||||
snapshotSerializers: ['enzyme-to-json/serializer'],
|
||||
setupFilesAfterEnv: ['../../hack/jestSetup.ts'],
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsconfig: '../../tsconfig.test.json',
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
"@roleypoly/types": "*"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"enzyme": "3.x",
|
||||
"@testing-library/react": "^12.1.2",
|
||||
"react": "*"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@ module.exports = {
|
|||
name: 'web',
|
||||
preset: 'ts-jest/presets/js-with-ts',
|
||||
testEnvironment: 'jsdom',
|
||||
reporters: ['default'],
|
||||
setupFilesAfterEnv: ['jest-styled-components', '../../hack/jestSetup.ts'],
|
||||
snapshotSerializers: ['enzyme-to-json/serializer'],
|
||||
setupFilesAfterEnv: ['../../hack/jestSetup.ts'],
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
tsconfig: '../../tsconfig.test.json',
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
"@types/react-helmet": "^6.1.5",
|
||||
"babel-loader": "8.2.3",
|
||||
"cross-env": "7.0.3",
|
||||
"jest": "^27.4.7",
|
||||
"ts-loader": "^9.2.6",
|
||||
"webpack": "5.67.0"
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue