Skip to content

Commit c20edbe

Browse files
committed
Added test for async webpack config support
1 parent 83f761b commit c20edbe

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ coverage
66

77
.idea
88
/.nyc_output
9+
.history

tests/validate.test.js

+22
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,28 @@ describe('validate', () => {
242242
});
243243
});
244244

245+
it('should load a async webpack config from file if `custom.webpack` is a string', () => {
246+
const testConfig = 'testconfig';
247+
const testServicePath = 'testpath';
248+
const requiredPath = path.join(testServicePath, testConfig);
249+
module.serverless.config.servicePath = testServicePath;
250+
module.serverless.service.custom.webpack = testConfig;
251+
serverless.utils.fileExistsSync = sinon.stub().returns(true);
252+
const loadedConfig = {
253+
entry: 'testentry',
254+
};
255+
const loadedConfigPromise = Promise.resolve(loadedConfig);
256+
mockery.registerMock(requiredPath, loadedConfigPromise);
257+
return module
258+
.validate()
259+
.then(() => {
260+
expect(serverless.utils.fileExistsSync).to.have.been.calledWith(requiredPath);
261+
expect(module.webpackConfig).to.eql(loadedConfig);
262+
mockery.deregisterMock(requiredPath);
263+
return null;
264+
});
265+
});
266+
245267
it('should throw if providing an invalid file', () => {
246268
const testConfig = 'testconfig';
247269
const testServicePath = 'testpath';

0 commit comments

Comments
 (0)