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';
|
import enableHooks from 'jest-react-hooks-shallow';
|
||||||
|
|
||||||
Enzyme.configure({ adapter: new Adapter() });
|
|
||||||
|
|
||||||
// pass an instance of jest to `enableHooks()`
|
// pass an instance of jest to `enableHooks()`
|
||||||
enableHooks(jest);
|
enableHooks(jest);
|
||||||
|
|
10
package.json
10
package.json
|
@ -43,17 +43,9 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@stylelint/postcss-css-in-js": "^0.37.2",
|
"@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",
|
"husky": "^7.0.4",
|
||||||
"is-ci": "^3.0.1",
|
"is-ci": "^3.0.1",
|
||||||
"jest": "27.4.7",
|
|
||||||
"jest-enzyme": "^7.1.2",
|
|
||||||
"jest-react-hooks-shallow": "^1.5.1",
|
"jest-react-hooks-shallow": "^1.5.1",
|
||||||
"jest-styled-components": "^7.0.8",
|
|
||||||
"lint-staged": "^12.3.2",
|
"lint-staged": "^12.3.2",
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"postcss-syntax": "^0.36.2",
|
"postcss-syntax": "^0.36.2",
|
||||||
|
@ -64,8 +56,6 @@
|
||||||
"stylelint": "^14.3.0",
|
"stylelint": "^14.3.0",
|
||||||
"stylelint-config-recommended": "^6.0.0",
|
"stylelint-config-recommended": "^6.0.0",
|
||||||
"stylelint-config-styled-components": "^0.1.1",
|
"stylelint-config-styled-components": "^0.1.1",
|
||||||
"stylelint-processor-styled-components": "^1.10.0",
|
|
||||||
"ts-jest": "^27.1.3",
|
|
||||||
"typescript": "^4.5.5"
|
"typescript": "^4.5.5"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
|
|
@ -42,10 +42,14 @@
|
||||||
"@types/react-dom": "^17.0.11",
|
"@types/react-dom": "^17.0.11",
|
||||||
"@types/react-helmet": "^6.1.5",
|
"@types/react-helmet": "^6.1.5",
|
||||||
"@types/styled-components": "^5.1.21",
|
"@types/styled-components": "^5.1.21",
|
||||||
|
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.6",
|
||||||
"babel-loader": "^8.2.3",
|
"babel-loader": "^8.2.3",
|
||||||
"babel-plugin-styled-components": "^2.0.2",
|
"babel-plugin-styled-components": "^2.0.2",
|
||||||
"change-case": "^4.1.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"
|
"typescript": "^4.5.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import { shallow } from 'enzyme';
|
import { render } from '@testing-library/react';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { ReactifyNewlines } from './ReactifyNewlines';
|
import { ReactifyNewlines } from './ReactifyNewlines';
|
||||||
|
|
||||||
it('renders a correct number of divs per newlines', () => {
|
it('renders a correct number of divs per newlines', async () => {
|
||||||
const view = shallow(<ReactifyNewlines>{`1\n2\n3`}</ReactifyNewlines>);
|
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 = {
|
module.exports = {
|
||||||
name: 'web',
|
|
||||||
preset: 'ts-jest/presets/js-with-ts',
|
preset: 'ts-jest/presets/js-with-ts',
|
||||||
testEnvironment: 'jsdom',
|
testEnvironment: 'jsdom',
|
||||||
reporters: ['default'],
|
setupFilesAfterEnv: ['../../hack/jestSetup.ts'],
|
||||||
setupFilesAfterEnv: ['jest-styled-components', '../../hack/jestSetup.ts'],
|
|
||||||
snapshotSerializers: ['enzyme-to-json/serializer'],
|
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsconfig: '../../tsconfig.test.json',
|
tsconfig: '../../tsconfig.test.json',
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
"@roleypoly/types": "*"
|
"@roleypoly/types": "*"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"enzyme": "3.x",
|
"@testing-library/react": "^12.1.2",
|
||||||
"react": "*"
|
"react": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,7 @@ module.exports = {
|
||||||
name: 'web',
|
name: 'web',
|
||||||
preset: 'ts-jest/presets/js-with-ts',
|
preset: 'ts-jest/presets/js-with-ts',
|
||||||
testEnvironment: 'jsdom',
|
testEnvironment: 'jsdom',
|
||||||
reporters: ['default'],
|
setupFilesAfterEnv: ['../../hack/jestSetup.ts'],
|
||||||
setupFilesAfterEnv: ['jest-styled-components', '../../hack/jestSetup.ts'],
|
|
||||||
snapshotSerializers: ['enzyme-to-json/serializer'],
|
|
||||||
globals: {
|
globals: {
|
||||||
'ts-jest': {
|
'ts-jest': {
|
||||||
tsconfig: '../../tsconfig.test.json',
|
tsconfig: '../../tsconfig.test.json',
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
"@types/react-helmet": "^6.1.5",
|
"@types/react-helmet": "^6.1.5",
|
||||||
"babel-loader": "8.2.3",
|
"babel-loader": "8.2.3",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
|
"jest": "^27.4.7",
|
||||||
"ts-loader": "^9.2.6",
|
"ts-loader": "^9.2.6",
|
||||||
"webpack": "5.67.0"
|
"webpack": "5.67.0"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue