This repository has been archived by the owner on May 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de34ba7
commit 31fcf24
Showing
8 changed files
with
1,059 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* eslint-env node */ | ||
|
||
module.exports = { | ||
cache: false, | ||
rootDir: process.cwd(), | ||
setupFiles: [ | ||
'<rootDir>/node_modules/fusion-cli/build/jest-framework-shims.js', | ||
'<rootDir>/node_modules/fusion-cli/build/jest-framework-setup.js', | ||
], | ||
transform: { | ||
'^.+\\.js$': '<rootDir>/node_modules/fusion-cli/build/jest-transformer.js', | ||
}, | ||
transformIgnorePatterns: ['/node_modules/(?!(fusion-cli.*build))'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-env node */ | ||
import {configure} from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
// Setup Enzyme for all Jest tests | ||
configure({adapter: new Adapter()}); | ||
|
||
const testEnv = process.env.ENV || 'browser'; | ||
global.__NODE__ = testEnv === 'node'; | ||
global.__BROWSER__ = testEnv === 'browser'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-env node */ | ||
global.requestAnimationFrame = callback => { | ||
setTimeout(callback, 0); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* eslint-env node */ | ||
|
||
const transformer = require('babel-jest').createTransformer({ | ||
presets: [ | ||
'babel-preset-flow', | ||
'babel-preset-es2015', | ||
'babel-preset-react', | ||
].map(require.resolve), | ||
}); | ||
|
||
const originalProcessFn = transformer.process; | ||
|
||
transformer.process = function(src, filename, config, transformOptions) { | ||
return originalProcessFn.call( | ||
transformer, | ||
src, | ||
filename, | ||
config, | ||
transformOptions | ||
); | ||
}; | ||
|
||
module.exports = transformer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* eslint-env node */ | ||
const path = require('path'); | ||
const {spawn} = require('child_process'); | ||
|
||
module.exports.TestAppRuntime = function({dir = '.'}) { | ||
const state = {proc: null}; | ||
|
||
this.run = () => { | ||
this.stop(); | ||
|
||
let command = require.resolve('jest-cli/bin/jest.js'); | ||
let args = [ | ||
'--no-cache', | ||
'--config', | ||
'./node_modules/fusion-cli/build/jest-config.js', | ||
]; | ||
|
||
return new Promise((resolve, reject) => { | ||
state.proc = spawn(command, args, { | ||
cwd: path.resolve(process.cwd(), dir), | ||
stdio: ['inherit', 'inherit', 'inherit', 'ipc'], | ||
env: Object.assign({}, process.env), | ||
}); | ||
|
||
state.proc.on('error', reject); | ||
state.proc.on('exit', (code, signal) => { | ||
if (code) { | ||
return reject(new Error(`Test exited with code ${code}`)); | ||
} | ||
|
||
if (signal) { | ||
return reject(new Error(`Test process exited with signal ${signal}`)); | ||
} | ||
|
||
return resolve(); | ||
}); | ||
}); | ||
}; | ||
|
||
this.stop = () => { | ||
if (state.proc) { | ||
state.proc.kill(); | ||
state.proc = null; | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* eslint-env node */ | ||
const {TestAppRuntime} = require('../build/test-app-runtime'); | ||
|
||
exports.desc = 'Run browser tests, using Jest'; | ||
exports.builder = { | ||
dir: { | ||
type: 'string', | ||
default: '.', | ||
describe: 'Root path for the application relative to CLI CWD', | ||
}, | ||
watch: { | ||
type: 'boolean', | ||
default: false, | ||
describe: 'Automatically re-profile your application on changes', | ||
}, | ||
}; | ||
|
||
exports.run = async function({dir = '.', watch}) { | ||
const testRuntime = new TestAppRuntime({dir, watch}); | ||
|
||
await testRuntime.run(); | ||
|
||
return { | ||
stop() { | ||
testRuntime.stop(); | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.