Skip to content

Commit

Permalink
Improve tests for compiling .tsx files
Browse files Browse the repository at this point in the history
  • Loading branch information
David Paz authored and davidmpaz committed Jun 24, 2017
1 parent ae1bea3 commit 822ceff
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions fixtures/js/render2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function render() {
document.getElementById('wrapper').innerHTML = "<h1> Hello World!</h1>";
}

export = render;
26 changes: 26 additions & 0 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,32 @@ module.exports = {
});
});

it('When enabled, react JSX and TypeScript work nice together!', (done) => {
const config = createWebpackConfig('www/build', 'dev');
config.setPublicPath('/build');
config.addEntry('main', ['./js/CoolReactComponent.jsx', './js/render2.tsx']);
config.enableReactPreset();
config.configureTypeScript(function(tsConfig) {
tsConfig.compilerOptions = { 'jsx': 'preserve' };
});

testSetup.runWebpack(config, (webpackAssert) => {
// check that babel transformed the JSX
webpackAssert.assertOutputFileContains(
'main.js',
'React.createElement'
);

// and also ts-loader did its job
webpackAssert.assertOutputFileContains(
'main.js',
'document.getElementById(\'wrapper\').innerHTML = "<h1> Hello World!</h1>";'
);

done();
});
});

it('The output directory is cleaned between builds', (done) => {
const config = createWebpackConfig('www/build', 'dev');
config.setPublicPath('/build');
Expand Down

0 comments on commit 822ceff

Please sign in to comment.