Skip to content

Commit e48942e

Browse files
Merge pull request #255 from conveyal/dev
Next release
2 parents b1337ba + bc97272 commit e48942e

File tree

9 files changed

+1538
-8
lines changed

9 files changed

+1538
-8
lines changed

__tests__/lib/__snapshots__/jest.js.snap

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ Array [
1414
"another-folder",
1515
],
1616
"coverageDirectory": "coverage",
17+
"moduleFileExtensions": Array [
18+
"js",
19+
"jsx",
20+
"json",
21+
"yml",
22+
],
1723
"notify": true,
1824
"setupFiles": Array [
1925
"beforeTestsSetup.js",

__tests__/lib/jest.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,15 @@ describe('jest.js', () => {
1515
updateSnapshots: true
1616
})
1717
cfg[JEST_CONFIG_INDEX] = JSON.parse(cfg[JEST_CONFIG_INDEX])
18-
expect(cfg[JEST_CONFIG_INDEX].transform['.*']).toContain(
18+
expect(cfg[JEST_CONFIG_INDEX].transform['^.+\\.jsx?$']).toContain(
1919
'lib/jest-preprocessor.js'
2020
)
2121
delete cfg[JEST_CONFIG_INDEX].transform
2222
expect(cfg).toMatchSnapshot()
2323
})
24+
25+
it('should be able to load a file that requires yaml', () => {
26+
const indexWithYaml = require('../test-utils/mocks/index-with-yaml')
27+
expect(indexWithYaml).toBeTruthy()
28+
})
2429
})

__tests__/lib/prepublish.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('prepublish', () => {
1717
env: 'development'
1818
})
1919

20-
expect(results).toHaveLength(1)
20+
expect(results).toHaveLength(2)
2121
})
2222

2323
it('should transpile a directory of files to a specific outdir', () => {
@@ -27,7 +27,7 @@ describe('prepublish', () => {
2727
outdir: buildDir
2828
})
2929

30-
expect(results).toHaveLength(1)
30+
expect(results).toHaveLength(2)
3131
})
3232

3333
it('should transpile entries', () => {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, {Component} from 'react'
2+
import uuid from 'uuid'
3+
4+
const yaml = require('./mock.yml')
5+
6+
/**
7+
* A Mock Component to test to ensure that building of React jsx components works
8+
*/
9+
export default class MockTestComponentUniqueName extends Component {
10+
static defaultProps = {
11+
test: 'hi'
12+
}
13+
14+
/**
15+
* Render the component.
16+
*/
17+
render () {
18+
console.log(yaml)
19+
console.log(uuid.v4())
20+
return <div />
21+
}
22+
}

__tests__/test-utils/mocks/mock.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- hi: there

lib/babel-config.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const react = require('@babel/preset-react')
55
const reactRequire = require('babel-plugin-react-require').default
66
const lodash = require('babel-plugin-lodash')
77
const reactDisplayName = require('@babel/plugin-transform-react-display-name')
8-
const transformRuntime = require('@babel/plugin-transform-runtime')
98
const classProperties = require('@babel/plugin-proposal-class-properties')
109
const exportFrom = require('@babel/plugin-proposal-export-namespace-from')
1110

@@ -18,8 +17,7 @@ module.exports = function (env) {
1817
exportFrom,
1918
lodash,
2019
reactDisplayName,
21-
reactRequire,
22-
transformRuntime
20+
reactRequire
2321
]
2422

2523
return {
@@ -29,7 +27,8 @@ module.exports = function (env) {
2927
babelEnv,
3028
{
3129
loose: false, // Loose mode breaks spread operator on `Set`s
32-
targets: { browsers }
30+
targets: { browsers },
31+
useBuiltIns: 'usage'
3332
}
3433
],
3534
flow,

lib/jest.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,22 @@ module.exports.generateTestConfig = (patterns, options) => {
88
collectCoverage: options.coverage,
99
collectCoverageFrom: ['lib/**/*.js'],
1010
coverageDirectory: 'coverage',
11+
moduleFileExtensions: [
12+
'js',
13+
'jsx',
14+
'json',
15+
'yml'
16+
],
1117
notify: true,
1218
testPathIgnorePatterns: [
1319
'<rootDir>/node_modules/',
1420
'<rootDir>/__tests__/test-utils'
1521
],
1622
testURL: 'http://localhost:9966',
17-
transform: { '.*': path.resolve(__dirname, 'jest-preprocessor.js') }
23+
transform: {
24+
'\\.yml$': 'jest-yaml-transform',
25+
'^.+\\.jsx?$': path.resolve(__dirname, 'jest-preprocessor.js')
26+
}
1827
}
1928

2029
if (options.coveragePaths) {

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
"glob": "^7.1.3",
9191
"isomorphic-fetch": "^2.2.1",
9292
"jest": "^23.5.0",
93+
"jest-yaml-transform": "^0.2.0",
9394
"lodash.uniq": "^4.5.0",
9495
"middleware-proxy": "^2.0.2",
9596
"mime": "^2.3.1",

0 commit comments

Comments
 (0)