mirror of
https://github.com/scratchfoundation/scratch-webpack-configuration.git
synced 2024-11-26 17:46:22 -05:00
test: add tests
This commit is contained in:
parent
75fd985720
commit
6979c28b3c
3 changed files with 4360 additions and 180 deletions
4490
package-lock.json
generated
4490
package-lock.json
generated
File diff suppressed because it is too large
Load diff
15
package.json
15
package.json
|
@ -5,7 +5,7 @@
|
|||
"main": "src/index.cjs",
|
||||
"type": "commonjs",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "jest"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -21,13 +21,18 @@
|
|||
"url": "https://github.com/scratchfoundation/scratch-webpack-configuration/issues"
|
||||
},
|
||||
"homepage": "https://github.com/scratchfoundation/scratch-webpack-configuration#readme",
|
||||
"dependencies": {
|
||||
"lodash.merge": "^4.6.2",
|
||||
"webpack-node-externals": "^3.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.5.12",
|
||||
"jest": "^29.7.0",
|
||||
"webpack": "^5.90.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/preset-env": "^7.24.0",
|
||||
"babel-loader": "^9.1.3",
|
||||
"webpack": "^5.90.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash.merge": "^4.6.2",
|
||||
"webpack-node-externals": "^3.0.0"
|
||||
}
|
||||
}
|
||||
|
|
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…
Reference in a new issue