forked from vega/voyager
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add infrastructure to support UI tests with Jest. Also add minimal test for lib-voyager.tsx * revert some package updates in an attempt to get ui tests working again * snapshot commit before possibly reverting changes. * Add infrastructure for running UI tests. Add some initial tests for app.tsx and lib-voyager.tsx * update tests to use ‘it’ instead of ‘test’. fixed up test.
- Loading branch information
Showing
8 changed files
with
543 additions
and
55 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,13 @@ | ||
{ | ||
"testPathDirs": [ | ||
"<rootDir>/lib/" | ||
], | ||
"testPathIgnorePatterns": [ | ||
"<rootDir>/node_modules/" | ||
], | ||
"testRegex": "(test\\.ui\\.(ts|tsx|jsx|js)\\.js$)", | ||
"moduleFileExtensions": [ | ||
"js" | ||
], | ||
"collectCoverage": false | ||
} |
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
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
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,40 @@ | ||
#!/usr/bin/env node | ||
|
||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
// const config = require('../config/webpack.config.dev'); | ||
const config = require('../config/webpack.lib.config'); | ||
const glob = require('glob'); | ||
|
||
|
||
const basedir = path.resolve(__dirname, '../src'); | ||
const tests = glob.sync('*.{test,spec}.ui.{ts,tsx,js,jsx}', { | ||
cwd: basedir, | ||
matchBase: true, | ||
}); | ||
|
||
config.entry = tests | ||
.reduce(function(carry, key) { | ||
carry[key] = path.resolve(basedir, key); | ||
return carry; | ||
}, {}); | ||
|
||
|
||
const compiler = webpack(config); | ||
compiler.run(function() {}); | ||
|
||
compiler.plugin('done', function(compilation) { | ||
|
||
if (process.env.NODE_ENV == null) { | ||
process.env.NODE_ENV = 'test'; | ||
} | ||
|
||
const jestConf = `--config ${path.resolve(__dirname, '../config', 'jest-ui.config.json')}`; | ||
|
||
try { | ||
require('jest-cli/build/cli').run(jestConf); | ||
} | ||
catch (_) { | ||
require('jest/node_modules/jest-cli/build/cli').run(jestConf); | ||
} | ||
}); |
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,78 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import {mount} from 'enzyme'; | ||
import * as React from 'react'; | ||
|
||
|
||
import {Provider} from 'react-redux'; | ||
import {configureStore} from '../store'; | ||
import {App} from './app'; | ||
|
||
describe('Voyager', () => { | ||
describe('instantiation via component', () => { | ||
it('renders voyager', done => { | ||
const config = {}; | ||
const data: any = undefined; | ||
const store = configureStore(); | ||
|
||
setTimeout(() => { | ||
try { | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<App | ||
config={config} | ||
data={data} | ||
dispatch={store.dispatch} | ||
/> | ||
</Provider>, | ||
); | ||
|
||
const header = wrapper.find('header'); | ||
expect(header.exists()); | ||
expect(header.text()).toContain('Voyager 2'); | ||
} catch (err) { | ||
done.fail(err); | ||
} | ||
done(); | ||
}, 10); | ||
}); | ||
|
||
it('renders voyager with custom data', done => { | ||
const config = {}; | ||
const data: any = { | ||
"values": [ | ||
{"fieldA": "A", "fieldB": 28}, {"fieldA": "B", "fieldB": 55}, {"fieldA": "C", "fieldB": 43}, | ||
{"fieldA": "D", "fieldB": 91}, {"fieldA": "E", "fieldB": 81}, {"fieldA": "F", "fieldB": 53}, | ||
{"fieldA": "G", "fieldB": 19}, {"fieldA": "H", "fieldB": 87}, {"fieldA": "I", "fieldB": 52} | ||
] | ||
}; | ||
const store = configureStore(); | ||
|
||
setTimeout(() => { | ||
try { | ||
const wrapper = mount( | ||
<Provider store={store}> | ||
<App | ||
config={config} | ||
data={data} | ||
dispatch={store.dispatch} | ||
/> | ||
</Provider>, | ||
); | ||
|
||
const fieldList = wrapper.find('.field-list__field-list-item'); | ||
const fields = fieldList.children().map(d => d.text()); | ||
|
||
expect(fields).toContain('fieldA'); | ||
expect(fields).toContain('fieldB'); | ||
|
||
done(); | ||
} catch (err) { | ||
done.fail(err); | ||
} | ||
}, 10); | ||
}); | ||
|
||
}); | ||
}); |
Oops, something went wrong.