chore: organize test files

This commit is contained in:
Igor Randjelovic
2020-12-01 19:25:29 +01:00
committed by Nathan Walker
parent 5181769328
commit 1cd6df370b
22 changed files with 339 additions and 140 deletions

View File

@@ -166,6 +166,12 @@ exports[`angular configuration for android 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'android'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -398,6 +404,12 @@ exports[`angular configuration for ios 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'ios'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{

View File

@@ -32,7 +32,8 @@ exports[`javascript configuration for android 1`] = `
'.android.scss',
'.scss',
'.android.json',
'.json'
'.json',
'.xml'
]
},
resolveLoader: {
@@ -170,6 +171,12 @@ exports[`javascript configuration for android 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'android'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -216,10 +223,14 @@ exports[`javascript configuration for android 1`] = `
),
/* config.plugin('WatchStatePlugin') */
new WatchStatePlugin(),
/* config.plugin('ContextExclusionPluginPlugin') */
new ContextExclusionPlugin(
/__virtual_entry__\\\\.js$/
),
/* config.plugin('VirtualModulesPlugin') */
new VirtualModulesPlugin(
{
'__jest__/src/__virtual_entry__.js': 'require(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js)$/);\\\\nglobal.registerWebpackModules(context);'
'__jest__/src/__virtual_entry__.js': 'require(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js|s?css)$/);\\\\nglobal.registerWebpackModules(context);'
}
)
],
@@ -265,7 +276,8 @@ exports[`javascript configuration for ios 1`] = `
'.ios.scss',
'.scss',
'.ios.json',
'.json'
'.json',
'.xml'
]
},
resolveLoader: {
@@ -403,6 +415,12 @@ exports[`javascript configuration for ios 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'ios'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -449,10 +467,14 @@ exports[`javascript configuration for ios 1`] = `
),
/* config.plugin('WatchStatePlugin') */
new WatchStatePlugin(),
/* config.plugin('ContextExclusionPluginPlugin') */
new ContextExclusionPlugin(
/__virtual_entry__\\\\.js$/
),
/* config.plugin('VirtualModulesPlugin') */
new VirtualModulesPlugin(
{
'__jest__/src/__virtual_entry__.js': 'require(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js)$/);\\\\nglobal.registerWebpackModules(context);'
'__jest__/src/__virtual_entry__.js': 'require(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js|s?css)$/);\\\\nglobal.registerWebpackModules(context);'
}
)
],

View File

@@ -175,6 +175,12 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'android'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -408,6 +414,12 @@ exports[`react configuration > android > base config 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'android'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -641,6 +653,12 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'ios'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -877,6 +895,12 @@ exports[`react configuration > ios > base config 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'ios'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{

View File

@@ -190,6 +190,12 @@ exports[`svelte configuration for android 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'android'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -436,6 +442,12 @@ exports[`svelte configuration for ios 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'ios'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{

View File

@@ -192,6 +192,12 @@ exports[`vue configuration for android 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'android'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{
@@ -440,6 +446,12 @@ exports[`vue configuration for ios 1`] = `
verbose: false
}
),
/* config.plugin('PlatformSuffixPlugin') */
new PlatformSuffixPlugin(
{
platform: 'ios'
}
),
/* config.plugin('DefinePlugin') */
new DefinePlugin(
{

View File

@@ -1,4 +1,3 @@
// @ts-ignore
import Config from 'webpack-chain';
import javascript from '../../src/configuration/javascript';
import { init } from '../../src';

View File

@@ -1,6 +1,7 @@
import Config from 'webpack-chain';
import svelte from '../../src/configuration/svelte';
import { init } from '../../src';
import { mockFile } from '../../scripts/jest.mockFiles';
mockFile('./svelte.config.js', '');
// jest.mock('__jest__/svelte.config.js', () => {

View File

@@ -42,7 +42,7 @@ describe('@nativescript/webpack', () => {
lastCalled = true;
expect(config.normal).toBe(true);
});
webpack.chainWebpack(chainFnLast, { last: true });
webpack.chainWebpack(chainFnLast, { order: 10 });
const chainFnNormal = jest.fn((config) => {
config.normal = true;
@@ -55,6 +55,22 @@ describe('@nativescript/webpack', () => {
webpack.resolveChainableConfig();
});
it('prints plugin name that errored out', () => {
webpack.useConfig(false);
webpack.setCurrentPlugin('test-plugin');
const chainFn = jest.fn(() => {
throw new Error('something wrong');
});
webpack.chainWebpack(chainFn);
// should not throw
expect(() => webpack.resolveChainableConfig()).not.toThrow();
expect(
'Unable to apply chain function from: test-plugin'
).toHaveBeenWarned();
});
it('applies merge configs', () => {
const dummyEnv = { env: true };
webpack.init(dummyEnv);