-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add basic server smoke test #172
Conversation
src/__tests__/server-smoke.test.ts
Outdated
jest.mock("../server", () => { | ||
const original = jest.requireActual("../server"); | ||
return { | ||
...original, | ||
ebbs: jest.fn() | ||
}; | ||
}); |
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 assume this doesn't work because the server.ts
code has an internal reference to ebbs
, which doesn't get replaced by this mock. I'd recommend refactoring startServer
to be more test-friendly by adding an optional argument which is a function to call to get the list of attached EBBs, defaulting to the internal ebbs
function when not specified.
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.
More or less - the solution I came up with was exporting a function and then having the module import itself, which allows jest
to mock that exported function. (In this case waitForEbb
)
After various iterations, I think 3388136 mocks the least amount of code / runs the most "real" code. What do you think?
Signed-off-by: Alex Ruddick <[email protected]>
Signed-off-by: Alex Ruddick <[email protected]>
|
Closing in favor of #187 |
Requires #170 since transient
superagent
silently dropped Node 12. (DefinitelyTyped/DefinitelyTyped#58445)This is a basic smoke test to make sure the Express server starts (sometimes dependency updates break it). It currently works, but has a warning:
I'm nearly certain this is caused by
server.ts
trying to connect to the EBB, but haven't quite figured out how to mock it out. Help would be appreciated.