mirror of
https://github.com/scratchfoundation/scratch-webpack-configuration.git
synced 2025-08-28 22:09:15 -04:00
test: add tests
This commit is contained in:
parent
75fd985720
commit
6979c28b3c
3 changed files with 4360 additions and 180 deletions
35
test/targets.test.js
Normal file
35
test/targets.test.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
const path = require('path');
|
||||
|
||||
const webpack = require('webpack');
|
||||
|
||||
const ScratchWebpackConfigBuilder = require('../src/index.cjs');
|
||||
|
||||
const common = {
|
||||
libraryName: 'test-library',
|
||||
rootPath: path.resolve(__dirname)
|
||||
};
|
||||
|
||||
describe('generating configurations for specific targets', () => {
|
||||
it('should should generate a valid configuration without a target', () => {
|
||||
const genericConfig = new ScratchWebpackConfigBuilder(common)
|
||||
.get();
|
||||
expect(genericConfig).not.toHaveProperty('target');
|
||||
expect(() => webpack.validate(genericConfig)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should should generate a valid `node` configuration', () => {
|
||||
const nodeConfig = new ScratchWebpackConfigBuilder(common)
|
||||
.setTarget('node')
|
||||
.get();
|
||||
expect(nodeConfig).toMatchObject({target: 'node'});
|
||||
expect(() => webpack.validate(nodeConfig)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should should generate a valid `browserslist` configuration', () => {
|
||||
const webConfig = new ScratchWebpackConfigBuilder(common)
|
||||
.setTarget('browserslist')
|
||||
.get();
|
||||
expect(webConfig).toMatchObject({target: 'browserslist'});
|
||||
expect(() => webpack.validate(webConfig)).not.toThrow();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue