Skip to content

Commit

Permalink
add functional test for svelte
Browse files Browse the repository at this point in the history
  • Loading branch information
zairigimad committed Apr 28, 2021
1 parent b7c9b74 commit 7d51db5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions fixtures/js/hello_world.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
let name = 'world';
</script>

<h1>Hello {name}!</h1>
2 changes: 0 additions & 2 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ class ConfigGenerator {
}

if (this.webpackConfig.useSvelte) {
loaderFeatures.ensurePackagesExistAndAreCorrectVersion('svelte');

rules.push(applyRuleConfigurationCallback('svelte', {
resolve: {
mainFields: ['svelte', 'browser', 'module', 'main'],
Expand Down
17 changes: 17 additions & 0 deletions test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,23 @@ module.exports = {
});
});

it('When enabled, svelte is transformed', (done) => {
const config = createWebpackConfig('www/build', 'dev');
config.setPublicPath('/build');
config.addEntry('main', './js/hello_world.svelte');
config.enableSvelte();

testSetup.runWebpack(config, (webpackAssert) => {
// check that babel transformed the svelte files
webpackAssert.assertOutputFileContains(
'main.js',
'SvelteComponent'
);

done();
});
});

it('When enabled, preact JSX is transformed with preact-compat!', (done) => {
const config = createWebpackConfig('www/build', 'dev');
config.setPublicPath('/build');
Expand Down

0 comments on commit 7d51db5

Please sign in to comment.