Skip to content

Commit 820ee48

Browse files
committed
add prod tests
1 parent e36919e commit 820ee48

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+296
-190
lines changed

.github/workflows/main.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ jobs:
5151
- name: Run Tests with React 18
5252
run: yarn test:react18:ci
5353

54+
test_prod:
55+
name: Test Prod
56+
runs-on: ubuntu-latest
57+
steps:
58+
- uses: actions/checkout@v3
59+
- uses: ./.github/actions/ci-setup
60+
61+
- name: Prod Tests
62+
run: yarn test:prod
63+
5464
test_dist:
5565
name: Test Dist
5666
runs-on: ubuntu-latest
@@ -59,7 +69,7 @@ jobs:
5969
- uses: ./.github/actions/ci-setup
6070

6171
- name: Dist Tests
62-
run: yarn test:prod
72+
run: yarn test:dist
6373

6474
linting:
6575
name: Linting

jest.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
'/site/',
1717
'/types/'
1818
],
19-
setupFilesAfterEnv: ['<rootDir>/test/testSetup.js'],
19+
setupFilesAfterEnv: ['test-utils/testSetup.js'],
2020
coveragePathIgnorePatterns: [
2121
'/node_modules/',
2222
'<rootDir>/packages/babel-plugin/test/util.js'

jest.prod.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const baseConfig = require('./jest.config.js')
2+
3+
module.exports = Object.assign({}, baseConfig, {
4+
testEnvironmentOptions: {
5+
...baseConfig.testEnvironmentOptions,
6+
customExportConditions:
7+
baseConfig.testEnvironmentOptions.customExportConditions.filter(
8+
c => c !== 'development'
9+
)
10+
}
11+
})

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"test:typescript": "yarn workspaces foreach --verbose --exclude emotion-monorepo run test:typescript",
1414
"test:ci": "jest --coverage --no-cache --ci --runInBand",
1515
"test:react18:ci": "yarn test:react18 --coverage --no-cache --ci --runInBand",
16-
"test:prod": "yarn build && jest -c jest.dist.js --no-cache --ci --runInBand",
16+
"test:dist": "yarn build && jest -c jest.dist.js --no-cache --ci --runInBand",
17+
"test:prod": "jest -c jest.prod.js --no-cache --ci --runInBand",
1718
"lint:check": "eslint .",
1819
"test:watch": "jest --watch",
1920
"size": "bundlesize",

packages/cache/__tests__/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test('throws correct error with invalid key', () => {
1111
}).toThrowErrorMatchingSnapshot()
1212
})
1313

14-
it('should accept insertionPoint option', () => {
14+
test('should accept insertionPoint option', () => {
1515
const head = safeQuerySelector('head')
1616

1717
head.innerHTML = `
@@ -34,7 +34,7 @@ it('should accept insertionPoint option', () => {
3434
expect(document.head).toMatchSnapshot()
3535
})
3636

37-
it('should accept container option', () => {
37+
test('should accept container option', () => {
3838
const body = safeQuerySelector('body')
3939

4040
body.innerHTML = `

packages/css/test/no-babel/warnings.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ afterEach(() => {
77
jest.clearAllMocks()
88
})
99

10-
it('warns about illegal escape sequences inside first quasi of template literal', () => {
10+
test('warns about illegal escape sequences inside first quasi of template literal', () => {
1111
css`
1212
:before {
1313
content: '\00d7';
@@ -24,7 +24,7 @@ it('warns about illegal escape sequences inside first quasi of template literal'
2424
`)
2525
})
2626

27-
it('warns about illegal escape sequences inside non-first quasi of template literal', () => {
27+
test('warns about illegal escape sequences inside non-first quasi of template literal', () => {
2828
const color = `color: hotpink`
2929
css`
3030
background-color: black;

packages/css/test/warnings.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ afterEach(() => {
3434
jest.clearAllMocks()
3535
})
3636

37-
it('does not warn when valid values are passed for the content property', () => {
37+
test('does not warn when valid values are passed for the content property', () => {
3838
const cls = css(validValues.map(value => ({ content: value })))
3939
expect(console.error).not.toBeCalled()
4040
expect(renderer.create(<div className={cls} />).toJSON()).toMatchSnapshot()
4141
})
4242

4343
const invalidValues = ['this is not valid', '']
4444

45-
it('does warn when invalid values are passed for the content property', () => {
45+
test('does warn when invalid values are passed for the content property', () => {
4646
invalidValues.forEach(value => {
4747
expect(() =>
4848
renderer.create(<div className={css({ content: value })} />)
@@ -52,14 +52,14 @@ it('does warn when invalid values are passed for the content property', () => {
5252
})
5353
})
5454

55-
it('does warn when functions are passed to css calls', () => {
55+
test('does warn when functions are passed to css calls', () => {
5656
css(() => 'color:hotpink;')
5757
expect(console.error).toBeCalledWith(
5858
"Functions that are interpolated in css calls will be stringified.\nIf you want to have a css call based on props, create a function that returns a css call like this\nlet dynamicStyle = (props) => css`color: ${props.color}`\nIt can be called directly with props or interpolated in a styled call like this\nlet SomeComponent = styled('div')`${dynamicStyle}`"
5959
)
6060
})
6161

62-
it('does warn when @import rule is being inserted after order-insensitive rules', () => {
62+
test('does warn when @import rule is being inserted after order-insensitive rules', () => {
6363
const { injectGlobal } = createCss({ key: 'import-after-regular' })
6464

6565
injectGlobal`.thing {display:flex;}`

packages/hash/__tests__/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import hash from '@emotion/hash'
22

3-
it('accepts a string and returns a string as a hash', () => {
3+
test('accepts a string and returns a string as a hash', () => {
44
expect(hash('something')).toBe('crsxd7')
55
})

packages/jest/test/matchers.test.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('toHaveStyleRule', () => {
2222
width: 100%;
2323
`
2424

25-
it('matches styles on the top-most node passed in', () => {
25+
test('matches styles on the top-most node passed in', () => {
2626
const tree = renderer
2727
.create(
2828
<div css={divStyle}>
@@ -40,7 +40,7 @@ describe('toHaveStyleRule', () => {
4040
expect(svgNode).not.toHaveStyleRule('color', 'red')
4141
})
4242

43-
it('supports asymmetric matchers', () => {
43+
test('supports asymmetric matchers', () => {
4444
const tree = renderer
4545
.create(
4646
<div css={divStyle}>
@@ -57,14 +57,14 @@ describe('toHaveStyleRule', () => {
5757
expect(svgNode).toHaveStyleRule('width', expect.stringMatching(/.*%$/))
5858
})
5959

60-
it('fails if no styles are found', () => {
60+
test('fails if no styles are found', () => {
6161
const tree = renderer.create(<div />).toJSON()
6262
const result = toHaveStyleRule(tree, 'color', 'red')
6363
expect(result.pass).toBe(false)
6464
expect(result.message()).toBe('Property not found: color')
6565
})
6666

67-
it('supports regex values', () => {
67+
test('supports regex values', () => {
6868
const tree = renderer.create(<div css={divStyle} />).toJSON()
6969
expect(tree).toHaveStyleRule('color', /red/)
7070
})
@@ -81,7 +81,7 @@ describe('toHaveStyleRule', () => {
8181
expect(resultPass.message()).toMatchSnapshot()
8282
})
8383

84-
it('matches styles on the focus, hover targets', () => {
84+
test('matches styles on the focus, hover targets', () => {
8585
const localDivStyle = css`
8686
color: white;
8787
&:hover {
@@ -104,7 +104,7 @@ describe('toHaveStyleRule', () => {
104104
expect(tree).toHaveStyleRule('color', 'white')
105105
})
106106

107-
it('matches styles on the nested component or html element', () => {
107+
test('matches styles on the nested component or html element', () => {
108108
const Svg = styled('svg')`
109109
width: 100%;
110110
fill: blue;
@@ -134,7 +134,7 @@ describe('toHaveStyleRule', () => {
134134
expect(tree).toHaveStyleRule('fill', 'green', { target: `${Svg}` })
135135
})
136136

137-
it('matches target styles by regex', () => {
137+
test('matches target styles by regex', () => {
138138
const localDivStyle = css`
139139
a {
140140
color: yellow;
@@ -154,7 +154,7 @@ describe('toHaveStyleRule', () => {
154154
expect(tree).toHaveStyleRule('color', 'yellow', { target: /a$/ })
155155
})
156156

157-
it('matches proper style for css', () => {
157+
test('matches proper style for css', () => {
158158
const tree = renderer
159159
.create(
160160
<div
@@ -169,7 +169,7 @@ describe('toHaveStyleRule', () => {
169169
expect(tree).toHaveStyleRule('color', 'hotpink')
170170
})
171171

172-
it('matches style of the media', () => {
172+
test('matches style of the media', () => {
173173
const Svg = styled('svg')`
174174
width: 100%;
175175
`
@@ -212,7 +212,7 @@ describe('toHaveStyleRule', () => {
212212
})
213213
})
214214

215-
it('matches styles with target and media options', () => {
215+
test('matches styles with target and media options', () => {
216216
const localDivStyle = css`
217217
color: white;
218218
@media (min-width: 420px) {
@@ -240,7 +240,7 @@ describe('toHaveStyleRule', () => {
240240
expect(tree).toHaveStyleRule('color', 'white')
241241
})
242242

243-
it('fails if option media invalid', () => {
243+
test('fails if option media invalid', () => {
244244
const Div = styled('div')`
245245
font-size: 30px;
246246
@media (min-width: 420px) {
@@ -257,7 +257,7 @@ describe('toHaveStyleRule', () => {
257257
expect(result.message()).toBe('Property not found: font-size')
258258
})
259259

260-
it('matches styles for a component used as selector', () => {
260+
test('matches styles for a component used as selector', () => {
261261
const Bar = styled.div``
262262

263263
const Foo = styled.div`
@@ -278,7 +278,7 @@ describe('toHaveStyleRule', () => {
278278
expect(tree.children[0]).toHaveStyleRule('color', 'hotpink')
279279
})
280280

281-
it('takes specificity into account when matching styles (basic)', () => {
281+
test('takes specificity into account when matching styles (basic)', () => {
282282
const Bar = styled.div`
283283
color: yellow;
284284
`
@@ -302,7 +302,7 @@ describe('toHaveStyleRule', () => {
302302
expect(tree.children[0]).toHaveStyleRule('color', 'hotpink')
303303
})
304304

305-
it('should throw a friendly error when it receives an array', () => {
305+
test('should throw a friendly error when it receives an array', () => {
306306
const tree = renderer
307307
.create(
308308
<>
@@ -323,7 +323,7 @@ describe('toHaveStyleRule', () => {
323323
)
324324
})
325325
;(isReact16 ? describe : describe.skip)('enzyme', () => {
326-
it('supports enzyme `mount` method', () => {
326+
test('supports enzyme `mount` method', () => {
327327
const Component = () => (
328328
<div css={divStyle}>
329329
<svg css={svgStyle} />
@@ -338,7 +338,7 @@ describe('toHaveStyleRule', () => {
338338
expect(svgNode).not.toHaveStyleRule('color', 'red')
339339
})
340340

341-
it('supports enzyme `render` method', () => {
341+
test('supports enzyme `render` method', () => {
342342
const Component = () => (
343343
<div css={divStyle}>
344344
<svg css={svgStyle} />
@@ -353,7 +353,7 @@ describe('toHaveStyleRule', () => {
353353
expect(svgNode).not.toHaveStyleRule('color', 'red')
354354
})
355355

356-
it('supports enzyme `shallow` method', () => {
356+
test('supports enzyme `shallow` method', () => {
357357
const Component = () => (
358358
<div css={divStyle}>
359359
<svg css={svgStyle} />
@@ -368,7 +368,7 @@ describe('toHaveStyleRule', () => {
368368
expect(svgNode).not.toHaveStyleRule('color', 'red')
369369
})
370370

371-
it('supports styled components', () => {
371+
test('supports styled components', () => {
372372
const Div = styled('div')`
373373
color: red;
374374
`

packages/jest/test/printer.test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('jest-emotion with dom elements', () => {
2222
width: 100%;
2323
`
2424

25-
it('replaces class names and inserts styles into React test component snapshots', () => {
25+
test('replaces class names and inserts styles into React test component snapshots', () => {
2626
const tree = renderer
2727
.create(
2828
<div css={divStyle}>
@@ -38,7 +38,7 @@ describe('jest-emotion with dom elements', () => {
3838
expect(output).toMatchSnapshot()
3939
})
4040

41-
it('replaces class names and inserts styles into DOM element snapshots', () => {
41+
test('replaces class names and inserts styles into DOM element snapshots', () => {
4242
const divRef = React.createRef()
4343
render(
4444
<div css={divStyle} ref={divRef}>
@@ -65,7 +65,7 @@ describe('jest-emotion with DOM elements disabled', () => {
6565
width: 100%;
6666
`
6767

68-
it('replaces class names and inserts styles into React test component snapshots', () => {
68+
test('replaces class names and inserts styles into React test component snapshots', () => {
6969
const tree = renderer
7070
.create(
7171
<div css={divStyle}>
@@ -81,7 +81,7 @@ describe('jest-emotion with DOM elements disabled', () => {
8181
expect(output).toMatchSnapshot()
8282
})
8383

84-
it('does not replace class names or insert styles into DOM element snapshots', () => {
84+
test('does not replace class names or insert styles into DOM element snapshots', () => {
8585
const divRef = React.createRef()
8686
render(
8787
<div css={divStyle} ref={divRef}>
@@ -150,7 +150,7 @@ describe('jest-emotion with nested selectors', () => {
150150
}
151151
`
152152

153-
it('replaces class names and inserts styles into React test component snapshots', () => {
153+
test('replaces class names and inserts styles into React test component snapshots', () => {
154154
const tree = renderer.create(<div css={divStyle} />).toJSON()
155155

156156
const output = prettyFormat(tree, {

packages/native/test/native-css.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ describe('Emotion native css', () => {
8080
).toEqual(['color', 'flex', 'backgroundColor', 'flexGrow', 'flexDirection'])
8181
})
8282

83-
it('allows function interpolations when this.mergedProps is defined', () => {
83+
test('allows function interpolations when this.mergedProps is defined', () => {
8484
expect(
8585
StyleSheet.flatten(
8686
css.call({ thing: true }, props => ({
@@ -90,7 +90,7 @@ describe('Emotion native css', () => {
9090
).toEqual({ color: 'hotpink' })
9191
})
9292

93-
it('works with nested functions', () => {
93+
test('works with nested functions', () => {
9494
expect(
9595
StyleSheet.flatten(
9696
css.call({ thing: true }, props => () => ({
@@ -100,7 +100,7 @@ describe('Emotion native css', () => {
100100
).toEqual({ color: 'hotpink' })
101101
})
102102

103-
it('works with functions in tagged template literals', () => {
103+
test('works with functions in tagged template literals', () => {
104104
expect(
105105
StyleSheet.flatten(
106106
css.call(

0 commit comments

Comments
 (0)