Skip to content

Commit

Permalink
Unit and Integration test separation configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
storrisi committed Jan 22, 2019
1 parent e5bbffc commit ebac1da
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}
7 changes: 7 additions & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const path = require('path')

module.exports = {
process(src, filename, config, options) {
return 'module.exports = {};'
}
}
7 changes: 7 additions & 0 deletions config/jest/assetsTransformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const path = require('path')

module.exports = {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';'
}
}
4 changes: 4 additions & 0 deletions jest.config.integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var config = require('./jest.config')
config.setupTestFrameworkScriptFile = '<rootDir>/src/setupTests.js'
console.log('RUNNING INTEGRATION TESTS')
module.exports = config
11 changes: 11 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
verbose: true,
moduleFileExtensions: ['js', 'jsx', 'json'],
moduleDirectories: ['node_modules'],
transform: {
'^.+\\.(js|jsx)?$': 'babel-jest',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/config/jest/assetsTransformer.js',
'\\.(css|less|sass|scss)$': '<rootDir>/__mocks__/styleMock.js'
}
}
4 changes: 4 additions & 0 deletions jest.config.unit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
var config = require('./jest.config')
config.testRegex = 'ispec\\.js$' //Overriding testRegex option
console.log('RUNNING UNIT TESTS')
module.exports = config
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,26 @@
"redux-thunk": "^2.3.0",
"spdx-expression-parse": "^3.0.0",
"spdx-expression-validate": "^1.0.2",
"spdx-license-ids": "^3.0.2",
"spdx-license-ids": "^3.0.3",
"throat": "^4.1.0",
"whatwg-fetch": "^2.0.4"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.3.0",
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.6.0",
"babel-preset-env": "^1.7.0",
"cpx": "^1.5.0",
"env-cmd": "^8.0.2",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-prettier": "^2.6.2",
"fetch-mock": "^7.1.0",
"identity-obj-proxy": "^3.0.0",
"jest-enzyme": "^6.0.2",
"jest-puppeteer": "^3.8.0",
"node-sass": "^4.9.0",
Expand All @@ -65,6 +72,8 @@
"start:prod-api": "env-cmd --fallback ./.env.production npm run build-scripts",
"build": "env-cmd --fallback ./.env.production npm run build-css && npm run copy-monaco && react-scripts build",
"test": "eslint src && react-scripts test --env=jsdom --coverage",
"test:unit": "jest -c jest.config.unit.js",
"test:integration": "jest -c jest.config.integration.js",
"eject": "react-scripts eject",
"e2e:start": "BROWSER=none PORT=3333 npm run start:dev-api",
"e2e:test": "jest -c e2e/jest.config.js"
Expand Down
1 change: 0 additions & 1 deletion src/components/InlineEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React, { Fragment } from 'react'
import PropTypes from 'prop-types'
import 'react-bootstrap-typeahead/css/Typeahead.css'
import Tooltip from 'antd/lib/tooltip'
import { SpdxPicker } from './'
import withSuggestions from '../utils/withSuggestions'
class InlineEditor extends React.Component {
Expand Down
File renamed without changes.

0 comments on commit ebac1da

Please sign in to comment.