-
Notifications
You must be signed in to change notification settings - Fork 160
feat: Mock of Serverless object for unit tests #144
Conversation
wbreza
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some feedback - let's discuss if not clear before merging.
src/test/mockFactory.ts
Outdated
| import PluginManager = require('serverless/classes/PluginManager'); | ||
|
|
||
| export class MockFactory { | ||
| public static createTestServerless(service?: Service, utils?: Utils, pluginManager?: PluginManager): Serverless { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you see a use case where we would want to manually create utils or pluginManager? I would expect if we wanted to mock any of those calls we would just spy/mock on them after instantiation.
src/test/mockFactory.ts
Outdated
| } | ||
| } | ||
|
|
||
| public static createTestPluginManager(): PluginManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change these to private if we don't expect to use them directly.
src/test/mockFactory.ts
Outdated
|
|
||
| export class MockFactory { | ||
| public static createTestServerless(service?: Service, utils?: Utils, pluginManager?: PluginManager): Serverless { | ||
| const sls = new Serverless(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should expose the serverless config param in this mock factory that gets passed into Serverless ctor.
No description provided.