File tree 12 files changed +68
-18
lines changed
12 files changed +68
-18
lines changed Original file line number Diff line number Diff line change 1
1
const isTest = String ( process . env . NODE_ENV ) === 'test'
2
+ const isProd = String ( process . env . NODE_ENV ) === 'production'
2
3
3
4
module . exports = {
4
5
presets : [
@@ -9,6 +10,15 @@ module.exports = {
9
10
'babel-plugin-syntax-dynamic-import' ,
10
11
'@babel/plugin-proposal-class-properties' ,
11
12
'@babel/plugin-proposal-object-rest-spread' ,
13
+ [
14
+ 'babel-plugin-emotion' ,
15
+ {
16
+ hoist : isProd ,
17
+ sourceMap : ! isProd ,
18
+ autoLabel : ! isProd ,
19
+ labelFormat : '[filename]--[local]' ,
20
+ } ,
21
+ ] ,
12
22
'react-loadable/babel' ,
13
23
isTest ? 'babel-plugin-dynamic-import-node' : null ,
14
24
] . filter ( Boolean ) ,
Original file line number Diff line number Diff line change 1
1
module . exports = {
2
- ...require ( './other /jest-common.js ' ) ,
2
+ ...require ( './test /jest-common' ) ,
3
3
collectCoverageFrom : [ '**/src/**/*.js' ] ,
4
4
coverageThreshold : {
5
5
global : {
@@ -16,8 +16,8 @@ module.exports = {
16
16
} ,
17
17
} ,
18
18
projects : [
19
- './other /jest.lint.js' ,
20
- './other /jest.client.js' ,
21
- './other /jest.server.js' ,
19
+ './test /jest.lint.js' ,
20
+ './test /jest.client.js' ,
21
+ './test /jest.server.js' ,
22
22
] ,
23
23
}
Original file line number Diff line number Diff line change 37
37
"babel-core" : " 7.0.0-bridge.0" ,
38
38
"babel-loader" : " ^7.1.4" ,
39
39
"babel-plugin-dynamic-import-node" : " ^1.2.0" ,
40
+ "babel-plugin-emotion" : " ^9.2.4" ,
40
41
"css-loader" : " ^0.28.11" ,
41
42
"cypress" : " ^3.0.1" ,
42
43
"cypress-testing-library" : " ^2.2.0" ,
44
+ "emotion" : " ^9.2.4" ,
43
45
"eslint" : " ^5.0.1" ,
44
46
"eslint-config-kentcdodds" : " ^14.0.0" ,
45
47
"file-loader" : " ^1.1.11" ,
48
50
"is-ci-cli" : " ^1.1.1" ,
49
51
"jest" : " ^23.1.0" ,
50
52
"jest-dom" : " ^1.3.1" ,
53
+ "jest-emotion" : " ^9.2.4" ,
51
54
"jest-runner-eslint" : " ^0.6.0" ,
52
55
"jest-watch-select-projects" : " 0.0.1" ,
53
56
"jest-watch-typeahead" : " ^0.1.0" ,
54
57
"lint-staged" : " ^7.2.0" ,
55
58
"prop-types" : " ^15.6.2" ,
59
+ "react-emotion" : " ^9.2.4" ,
56
60
"react-testing-library" : " ^4.0.2" ,
57
61
"serve" : " ^9.1.0" ,
58
62
"start-server-and-test" : " ^1.4.1" ,
Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` mounts 1` ] = `
4
+ .emotion-0 {
5
+ color : white ;
6
+ background : #1c191c ;
7
+ line - height : 130px ;
8
+ font - size : 6em ;
9
+ - webkit - flex : 1 ;
10
+ - ms - flex : 1 ;
11
+ flex : 1 ;
12
+ }
13
+
14
+ <div
15
+ class = " emotion-0"
16
+ >
17
+ <div
18
+ class = " autoScalingText"
19
+ style = " transform: scale(1,1);"
20
+ >
21
+ 0
22
+ </div >
23
+ </div >
24
+ ` ;
Original file line number Diff line number Diff line change
1
+ import React from 'react'
2
+ import { render } from 'react-testing-library'
3
+ import CalculatorDisplay from '../calculator-display'
4
+
5
+ test ( 'mounts' , ( ) => {
6
+ const { container} = render ( < CalculatorDisplay value = "0" /> )
7
+ expect ( container . firstChild ) . toMatchSnapshot ( )
8
+ } )
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import PropTypes from 'prop-types'
3
3
import AutoScalingText from './auto-scaling-text'
4
- import styles from './calculator-display.module.css'
5
4
import { getFormattedValue } from './utils'
6
5
7
6
class CalculatorDisplay extends React . Component {
@@ -16,7 +15,16 @@ class CalculatorDisplay extends React.Component {
16
15
)
17
16
18
17
return (
19
- < div { ...props } className = { styles . calculatorDisplay } >
18
+ < div
19
+ { ...props }
20
+ css = { {
21
+ color : 'white' ,
22
+ background : '#1c191c' ,
23
+ lineHeight : '130px' ,
24
+ fontSize : '6em' ,
25
+ flex : '1' ,
26
+ } }
27
+ >
20
28
< AutoScalingText > { formattedValue } </ AutoScalingText >
21
29
</ div >
22
30
)
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module.exports = {
8
8
moduleNameMapper : {
9
9
// module must come first
10
10
'\\.module\\.css$' : 'identity-obj-proxy' ,
11
- '\\.css$' : require . resolve ( '../test /style-mock.js' ) ,
11
+ '\\.css$' : require . resolve ( './style-mock.js' ) ,
12
12
// can also map files that are loaded by webpack with the file-loader
13
13
} ,
14
14
coveragePathIgnorePatterns : [
Original file line number Diff line number Diff line change @@ -2,7 +2,5 @@ module.exports = {
2
2
...require ( './jest-common' ) ,
3
3
displayName : 'dom' ,
4
4
testEnvironment : 'jest-environment-jsdom' ,
5
- setupTestFrameworkScriptFile : require . resolve (
6
- '../test/setup-test-framework.js' ,
7
- ) ,
5
+ setupTestFrameworkScriptFile : require . resolve ( './setup-test-framework.js' ) ,
8
6
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change @@ -4,3 +4,9 @@ import 'react-testing-library/cleanup-after-each'
4
4
5
5
// this adds jest-dom's custom assertions
6
6
import 'jest-dom/extend-expect'
7
+
8
+ // add jest-emotion serializer
9
+ import { createSerializer } from 'jest-emotion'
10
+ import * as emotion from 'emotion'
11
+
12
+ expect . addSnapshotSerializer ( createSerializer ( emotion ) )
You can’t perform that action at this time.
0 commit comments