Commit 17c4d39e authored by Yannis Barlas's avatar Yannis Barlas

chore: use enzyme for react testing

parent 13546c1c
{
"linters": {
"*.{js,jsx}": ["prettier --write", "eslint --fix", "git add"]
"*.js": ["prettier --write", "eslint --fix", "git add"]
},
"ignore": ["**/CHANGELOG.md"]
}
......@@ -25,7 +25,6 @@ const Dashboard = () => (
<h1>The Dashboard!</h1>
<h1>The Dashboard!</h1>
<h1>The Dashboard!</h1>
<h1>The Dashboard!</h1>
</div>
)
......
test('the dash', () => {
expect(3).toEqual(3)
})
import React from 'react'
import { shallow } from 'enzyme'
import Dashboard from '../components/Dashboard'
describe('Dashboard', () => {
it('matches the snapshot', () => {
const wrapper = shallow(<Dashboard />)
expect(wrapper).toMatchSnapshot()
})
})
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Dashboard matches the snapshot 1`] = `
<div>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
<h1>
The Dashboard!
</h1>
</div>
`;
/* eslint-disable import/no-extraneous-dependencies */
import { configure } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
configure({ adapter: new Adapter() })
......@@ -57,6 +57,7 @@
"@commitlint/config-conventional": "^7.0.1",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-jest": "^23.0.1",
"babel-loader": "^7.1.4",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-env": "^1.7.0",
......@@ -66,6 +67,9 @@
"commitizen": "^2.10.1",
"css-loader": "^0.28.11",
"cz-conventional-changelog": "^2.1.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.4",
"eslint": "^4.19.1",
"eslint-config-pubsweet": "^0.0.6",
"eslint-plugin-import": "^2.12.0",
......@@ -93,6 +97,7 @@
"scripts": {
"commitmsg": "commitlint -E GIT_PARAMS",
"cz": "git-cz",
"lint": "eslint '**/*.js' && stylelint '**/*.js'",
"precommit": "lint-staged",
"release": "standard-version",
"server": "pubsweet server",
......@@ -103,5 +108,11 @@
"commitizen": {
"path": "cz-conventional-changelog"
}
},
"jest": {
"setupTestFrameworkScriptFile": "./app/test/setup.js",
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
}
}
/* eslint-disable sort-keys */
// const path = require('path')
const config = require('config')
const babelIncludes = require('./babel-includes')
......@@ -13,7 +15,7 @@ const resolvePreset = entry => resolve('preset', entry)
const resolvePlugin = entry => resolve('plugin', entry)
const clientComponents = config.pubsweet.components.filter(name => {
// eslint-disable-next-line global-require
// eslint-disable-next-line global-require, import/no-dynamic-require
const component = require(name)
// Backwards compatibility - old name was 'frontend', new name is 'client'
return component.client || component.frontend
......
/* eslint-disable sort-keys */
const path = require('path')
const webpack = require('webpack')
// const ThemePlugin = require('pubsweet-theme-plugin')
......
......@@ -3530,7 +3530,13 @@ enzyme-adapter-utils@^1.3.0:
object.assign "^4.0.4"
prop-types "^15.6.0"
enzyme@^3.2.0:
enzyme-to-json@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/enzyme-to-json/-/enzyme-to-json-3.3.4.tgz#67c6040e931182f183418af2eb9f4323258aa77f"
dependencies:
lodash "^4.17.4"
enzyme@^3.2.0, enzyme@^3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.3.0.tgz#0971abd167f2d4bf3f5bd508229e1c4b6dc50479"
dependencies:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment