-
-
Notifications
You must be signed in to change notification settings - Fork 433
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #681 from christiantinauer/master
Add new loader option "contextAsConfigBasePath", which when set to tr…
- Loading branch information
Showing
18 changed files
with
1,176 additions
and
8 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
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
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
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
45 changes: 45 additions & 0 deletions
45
test/execution-tests/option-contextAsConfigBasePath/karma.conf.js
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,45 @@ | ||
/* eslint-disable no-var, strict */ | ||
'use strict'; | ||
var webpackConfig = require('./webpack.config.js'); | ||
var reporterOptions = require('../../reporterOptions'); | ||
|
||
module.exports = function(config) { | ||
// Documentation: https://karma-runner.github.io/0.13/config/configuration-file.html | ||
config.set({ | ||
browsers: [ 'ChromeHeadless' ], | ||
|
||
files: [ | ||
// This ensures we have the es6 shims in place and then loads all the tests | ||
'main.js' | ||
], | ||
|
||
port: 9876, | ||
|
||
frameworks: [ 'jasmine' ], | ||
|
||
logLevel: config.LOG_INFO, //config.LOG_DEBUG | ||
|
||
preprocessors: { | ||
'main.js': [ 'webpack', 'sourcemap' ] | ||
}, | ||
|
||
webpack: { | ||
devtool: 'inline-source-map', | ||
module: webpackConfig.module, | ||
resolve: webpackConfig.resolve, | ||
|
||
// for test harness purposes only, you would not need this in a normal project | ||
resolveLoader: webpackConfig.resolveLoader | ||
}, | ||
|
||
webpackMiddleware: { | ||
quiet: true, | ||
stats: { | ||
colors: true | ||
} | ||
}, | ||
|
||
// reporter options | ||
mochaReporter: reporterOptions | ||
}); | ||
}; |
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 @@ | ||
import 'babel-polyfill'; | ||
|
||
const testsContext = require.context('./', true, /\.tests\.ts(x?)$/); | ||
testsContext.keys().forEach(testsContext); |
26 changes: 26 additions & 0 deletions
26
test/execution-tests/option-contextAsConfigBasePath/package.json
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,26 @@ | ||
{ | ||
"name": "es6-babel-react", | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"devDependencies": { | ||
"@types/jasmine": "^2.5.35", | ||
"@types/react": "^0.14.41", | ||
"@types/react-addons-test-utils": "^0.14.15", | ||
"@types/react-test-renderer": "^15.5.0", | ||
"@types/react-dom": "^0.14.18", | ||
"babel": "^6.0.0", | ||
"babel-core": "^6.0.0", | ||
"babel-loader": "^7.0.0", | ||
"babel-preset-es2015": "^6.0.0", | ||
"babel-preset-react": "^6.0.0", | ||
"jasmine-core": "^2.3.4", | ||
"react-addons-test-utils": "^15.3.1", | ||
"react-test-renderer": "^15.5.4" | ||
}, | ||
"dependencies": { | ||
"babel-polyfill": "^6.0.0", | ||
"react": "^15.4.1", | ||
"react-dom": "^15.4.1" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
test/execution-tests/option-contextAsConfigBasePath/src/components/App.tsx
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,8 @@ | ||
import React from 'react'; | ||
|
||
const App: React.SFC<{ name: string }> = ({ name }) => | ||
<div className="container-fluid"> | ||
<h1>Hello {name}!</h1> | ||
</div>; | ||
|
||
export default App; |
7 changes: 7 additions & 0 deletions
7
test/execution-tests/option-contextAsConfigBasePath/src/main.tsx
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,7 @@ | ||
import 'babel-polyfill'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import App from './components/App'; | ||
|
||
ReactDOM.render(<App name="James" />, document.getElementById('content')); |
21 changes: 21 additions & 0 deletions
21
test/execution-tests/option-contextAsConfigBasePath/test/components/App.tests.tsx
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,21 @@ | ||
import React from 'react'; | ||
import { createRenderer } from 'react-test-renderer/shallow'; | ||
|
||
import App from '../../src/components/App'; | ||
|
||
describe('App', () => { | ||
it('simple', () => expect(1).toBe(1)); | ||
|
||
it('renders expected HTML', () => { | ||
const shallowRenderer = createRenderer(); | ||
|
||
shallowRenderer.render(<App name="James" />); | ||
const app = shallowRenderer.getRenderOutput(); | ||
|
||
expect(app).toEqual( | ||
<div className="container-fluid"> | ||
<h1>Hello { "James" }!</h1> | ||
</div> | ||
); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
test/execution-tests/option-contextAsConfigBasePath/tsconfig-container/tsconfig.json
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,20 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowSyntheticDefaultImports": true, | ||
"lib": [ | ||
"dom", | ||
"es2015" | ||
], | ||
"jsx": "preserve", | ||
"target": "es2015", | ||
"module": "es2015", | ||
"moduleResolution": "node", | ||
"noImplicitAny": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"removeComments": false, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
"skipLibCheck": true | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
test/execution-tests/option-contextAsConfigBasePath/webpack.config.js
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,60 @@ | ||
/* eslint-disable no-var, strict, prefer-arrow-callback */ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var webpack = require('webpack'); | ||
|
||
var babelOptions = { | ||
"presets": [ | ||
"react", | ||
[ | ||
"es2015", | ||
{ | ||
"modules": false | ||
} | ||
], | ||
"es2016" | ||
] | ||
}; | ||
|
||
module.exports = { | ||
entry: './src/main.tsx', | ||
output: { | ||
filename: 'bundle.js' | ||
}, | ||
module: { | ||
rules: [{ | ||
test: /\.ts(x?)$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: babelOptions | ||
}, | ||
{ | ||
loader: 'ts-loader', | ||
options: { | ||
contextAsConfigBasePath: true, | ||
configFile: require.resolve('./tsconfig-container/tsconfig.json') | ||
} | ||
} | ||
] | ||
}, { | ||
test: /\.js$/, | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: babelOptions | ||
} | ||
] | ||
}] | ||
}, | ||
resolve: { | ||
// Add `.ts` and `.tsx` as a resolvable extension. | ||
extensions: ['.ts', '.tsx', '.js'] | ||
}, | ||
}; | ||
|
||
// for test harness purposes only, you would not need this in a normal project | ||
module.exports.resolveLoader = { alias: { 'ts-loader': path.join(__dirname, "../../../index.js") } } |
Oops, something went wrong.