Skip to content
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

!Don't merge yet! Add unit tests #12

Closed
wants to merge 6 commits into from
Closed

!Don't merge yet! Add unit tests #12

wants to merge 6 commits into from

Conversation

sadym-chromium
Copy link
Collaborator

@sadym-chromium sadym-chromium commented Jul 2, 2021

UPD: Still not sure if the ts-mockito is the best choice. It has a nice interface and some advantages comparing to Sinon, like automatic creating mock by interfaces. But it looks like it has poor support: NagRock/ts-mockito#212

@sadym-chromium sadym-chromium requested a review from foolip July 2, 2021 17:20
@sadym-chromium sadym-chromium changed the title Unit Add Unit tests Jul 2, 2021
.gitignore Outdated Show resolved Hide resolved
src/bidiMapper/utils/log.ts Outdated Show resolved Hide resolved
src/bidiMapper/utils/log.ts Outdated Show resolved Hide resolved
src/bidiMapper/utils/log.ts Outdated Show resolved Hide resolved
@mathiasbynens mathiasbynens changed the title Add Unit tests Add unit tests Jul 5, 2021
@sadym-chromium sadym-chromium force-pushed the unit branch 2 times, most recently from acf3841 to 6dcf6c1 Compare July 5, 2021 08:21
Copy link
Collaborator

@bwalderman bwalderman left a comment

Choose a reason for hiding this comment

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

LGTM! Just left one minor comment on test naming.

@sadym-chromium sadym-chromium self-assigned this Jul 12, 2021
@sadym-chromium sadym-chromium linked an issue Jul 12, 2021 that may be closed by this pull request
Base automatically changed from wpt to main July 13, 2021 14:37
@@ -15,16 +15,18 @@
*/
export function log(type: string): (...message: any[]) => void {
return (...messages: any[]) => {
const elementId = type + '_log';
console.log(type, ...messages);
Copy link
Member

Choose a reason for hiding this comment

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

This (or some other console.log) is showing up in the output of npm run unit, I see this:

  CdpServer tests.
cdp sent > {"someAttribute":"someValue","id":0}
    ✔ given CdpServer, when `sendMessage` is called, then cdpBindings should be called with proper values

That "cdp sent" line would be nice to get rid of. If there is logging that's useful for debugging, then we should probably use a logging mechanism which can be disabled when running tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done. Log only if run in browser.


const server = http.createServer(function (request, response) {
debugInternal(new Date() + ' Received request for ' + request.url);
response.writeHead(404);

// Needed for WPT compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

This was already landed in https://github.com/GoogleChromeLabs/chromium-bidi/pull/7/files, why is it also showing up in this PR despite #7 being merged?

Hmm, I think it's because there are conflicts in package.json, so GitHub can't merge into main in order to compare against main...

Copy link
Collaborator Author

@sadym-chromium sadym-chromium Jul 14, 2021

Choose a reason for hiding this comment

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

rebased

@foolip
Copy link
Member

foolip commented Jul 13, 2021

On the mocking library to use, I've used Sinon with pure JS before. I don't exactly love it, but it gets the job done. Would it work to depend on Sinon and https://www.npmjs.com/package/@types/sinon perhaps? That has a lot of downloads at least, suggesting we'd not be alone :)

@sadym-chromium sadym-chromium changed the title Add unit tests !Don't merge yet! Add unit tests Jul 16, 2021
@bwalderman
Copy link
Collaborator

@sadym-chromium , thanks for adding this. My next PR will bring some big changes to CdpClient, so it might be best to wait before creating a CdpClient unit test. Thanks!

@sadym-chromium
Copy link
Collaborator Author

sadym-chromium commented Jul 19, 2021

Closed in favour of #20, as Sinon appeared to be quite ergonomic for our needs.

@sadym-chromium sadym-chromium deleted the unit branch October 7, 2021 21:49
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.

Add UnitTest infrustructure
4 participants