Skip to content

Commit 356aaa2

Browse files
committed
Make tests check for content in browser context
* Update fixtures to insert content inside #app div * Add assertion for requestTestPage and files generated.
1 parent 822ceff commit 356aaa2

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

fixtures/js/render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function render() {
2-
document.getElementById('wrapper').innerHTML = "<h1> Hello World!</h1>";
2+
document.getElementById('app').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";
33
}
44

55
export = render;

fixtures/js/render2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function render() {
2-
document.getElementById('wrapper').innerHTML = "<h1> Hello World!</h1>";
2+
document.getElementById('app').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";
33
}
44

55
export = render;

lib/test/setup.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ function requestTestPage(webRootDir, scriptSrcs, callback) {
140140
<head>
141141
</head>
142142
<body>
143+
<div id="app"></div>
143144
${scripts}
144145
</body>
145146
</html>

test/functional.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,29 @@ module.exports = {
594594
// check that ts-loader transformed the ts file
595595
webpackAssert.assertOutputFileContains(
596596
'main.js',
597-
'document.getElementById(\'wrapper\').innerHTML = "<h1> Hello World!</h1>";'
597+
'document.getElementById(\'app\').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";'
598598
);
599599

600-
done();
600+
expect(config.outputPath).to.be.a.directory().with.deep.files([
601+
'main.js',
602+
'manifest.json'
603+
]);
604+
605+
testSetup.requestTestPage(
606+
path.join(config.getContext(), 'www'),
607+
[
608+
'build/main.js'
609+
],
610+
(browser) => {
611+
612+
// assert that the ts module rendered
613+
browser.assert.text('#app h1', 'Welcome to Your TypeScript App');
614+
// make sure the styles are not inline
615+
browser.assert.elements('style', 0);
616+
617+
done();
618+
}
619+
);
601620
});
602621
});
603622

@@ -620,9 +639,14 @@ module.exports = {
620639
// and also ts-loader did its job
621640
webpackAssert.assertOutputFileContains(
622641
'main.js',
623-
'document.getElementById(\'wrapper\').innerHTML = "<h1> Hello World!</h1>";'
642+
'document.getElementById(\'app\').innerHTML = "<h1>Welcome to Your TypeScript App</h1>";'
624643
);
625644

645+
expect(config.outputPath).to.be.a.directory().with.deep.files([
646+
'main.js',
647+
'manifest.json'
648+
]);
649+
626650
done();
627651
});
628652
});

0 commit comments

Comments
 (0)