Skip to content

Conversation

@nicojs
Copy link
Member

@nicojs nicojs commented Feb 19, 2024

Add real-time package. It is a helper package to help with the nodejs side of a real-time report. It abstracts away all the nitty gritty server-send events stuff underneath.

Add real-time package. It is a helper package to help with the nodejs side of a real-time report. It abstracts away all the nitty gritty server-send events stuff underneath.
@nicojs nicojs requested a review from xandervedder February 19, 2024 12:09
@bundlemon
Copy link

bundlemon bot commented Feb 19, 2024

BundleMon (elements)

Unchanged files (3)
Status Path Size Limits
index.js
266.19KB -
mutation-test-elements.js
194.92KB -
index.cjs
194.92KB -

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

let onCompleteStub: sinon.SinonStub<[], void>;

beforeEach(() => {
responseMock = sinon.createStubInstance(ServerResponse);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a bit strange to me to make a stub instance for something like a http response. Is it not possible to make the object ourselves and spy on it? Especially since the sut is doing quite a lot of side-effect calling on the response this doesn't give me faith that it is being used properly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a unit test. I want to avoid creating an actual response.

Do you mean to say it's better to write a custom fake that implements the ServerResponse interface?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I expected ServerResponse to just be a data object carrying some stream objects or something. That way you could test the streams. If that's not the case, this might be the simplest approach. Then a custom fake doesn't have much advantage over a stub

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I understand. But it is more complex than a data object. The docs give a hint:

This object is created internally by an HTTP server, not by the user. It is passed as the second parameter to the 'request' event.

We also cannot depend on a class higher up, since we are using the writeHead method, which is implemented on the ServerResponse class directly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I clearly expected too much 🙃

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't you learned by now? This is JavaScript after all 😉

Copy link
Contributor

@xandervedder xandervedder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking forward to use this in stryker-dashboard! 🥳

@nicojs
Copy link
Member Author

nicojs commented Feb 20, 2024

@hugo-vrijswijk I've commented on both remarks you've made. Could you take a look and answer my questions?

Copy link
Member

@hugo-vrijswijk hugo-vrijswijk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicojs not sure if you were waiting for specific approval from my side but this looks good 👍

@nicojs nicojs enabled auto-merge (squash) February 22, 2024 14:40
@nicojs nicojs merged commit c887bf9 into master Feb 22, 2024
@nicojs nicojs deleted the feat/real-time branch February 22, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants