Skip to content
Permalink
Browse files

Move unit tests to Jest + enzyme-to-json snapshots

  • Loading branch information...
jrajav committed Mar 4, 2019
1 parent 4305ed2 commit 9f62e7c8dbb264109868088e9d583357a6688c09
Showing with 683 additions and 219 deletions.
  1. +7 −1 .babelrc
  2. +18 −0 jest.config.json
  3. +8 −4 package.json
  4. +7 −17 test/Omni-button.spec.tsx
  5. +11 −0 test/__snapshots__/Omni-button.spec.tsx.snap
  6. +0 −29 test/setup.js
  7. +5 −0 test/setup.ts
  8. +627 −168 yarn.lock
@@ -10,5 +10,11 @@
"@babel/react",
"@babel/preset-typescript"
],
"plugins": ["transform-object-rest-spread"]
"plugins": ["@babel/plugin-proposal-object-rest-spread"],
"env": {
"test": {
"presets": ["@babel/env", "@babel/react", "@babel/preset-typescript"],
"plugins": ["@babel/plugin-proposal-object-rest-spread"]
}
}
}
@@ -0,0 +1,18 @@
{
"automock": false,
"transform": {
"^.+\\.jsx?$": "babel-jest",
"^.+\\.tsx?$": "babel-jest"
},
"moduleFileExtensions": ["js", "jsx", "ts", "tsx"],
"setupFiles": ["./test/setup.ts"],
"snapshotSerializers": ["enzyme-to-json/serializer"],
"moduleNameMapper": {
"\\.scss$": "identity-obj-proxy"
},
"collectCoverageFrom": ["src/**/*.{js,jsx,ts,tsx}"],
"coverageDirectory": "coverage",
"coverageReporters": ["html"],
"testMatch": ["**/?(*.)(spec|test).js?(x)", "**/?(*.)(spec|test).ts?(x)"],
"testURL": "http://localhost/"
}
@@ -17,7 +17,7 @@
"prod": "webpack --env.prod --watch",
"dev": "webpack --env.dev --watch",
"clean": "yarn cache clean && rm -rf node_modules",
"test": "mocha-webpack test/**/*.spec.* --require test/setup.js --webpack-env.dev --webpack-config webpack.config.js --watch",
"test": "jest --config jest.config.json",
"format": "eslint \"src/**/*.js\" --fix",
"styleguide": "styleguidist server",
"styleguide:build": "styleguidist build"
@@ -59,20 +59,24 @@
"typescript": "3.3.3333"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.47",
"@babel/core": "7.3.4",
"@babel/plugin-proposal-object-rest-spread": "^7.3.4",
"@babel/plugin-transform-runtime": "7.3.4",
"@babel/preset-env": "7.3.4",
"@babel/preset-react": "7.0.0",
"@babel/preset-typescript": "7.0.0-beta.42",
"@babel/preset-typescript": "7.3.3",
"autoprefixer": "9.4.9",
"babel-eslint": "10.0.1",
"babel-jest": "^24.1.0",
"babel-loader": "8.0.5",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"chai": "4.2.0",
"css-loader": "2.1.0",
"enzyme-to-json": "^3.3.5",
"eslint": "5.15.0",
"extract-text-webpack-plugin": "4.0.0-alpha.0",
"identity-obj-proxy": "^3.0.0",
"ink-docstrap": "1.3.2",
"jest": "^24.1.0",
"jsdoc": "3.5.5",
"jsdom": "13.2.0",
"json-loader": "0.5.7",
@@ -1,21 +1,11 @@
import React from 'react';
import { shallow } from "enzyme"
import { expect } from "chai"
import React from "react"
import {render} from "enzyme"

import { configure } from "enzyme"
import Adapter from "enzyme-adapter-react-16"
configure({ adapter: new Adapter() })
import OmniButton from "../src/components/Omni-button"

import OmniButton from '../src/components/Omni-button.tsx';
test("Should render a button", () => {
const props = {}
const component = render(<OmniButton {...props} />)

describe("render components", () => {

it("should render a button", () => {
const props = {}
const wrapper = shallow(<OmniButton {...props} />)

expect(wrapper.find({ className: "omni-button" })).to.have.length(
1
)
})
expect(component).toMatchSnapshot()
})
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Should render a button 1`] = `
<button
class="mdc-button omni-button"
>
<span
class="mdc-button__label"
/>
</button>
`;

This file was deleted.

@@ -0,0 +1,5 @@
import Enzyme from "enzyme"
import Adapter from "enzyme-adapter-react-16"


Enzyme.configure({adapter: new Adapter()})

0 comments on commit 9f62e7c

Please sign in to comment.
You can’t perform that action at this time.