Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

Unit tests for library #156

Merged
merged 54 commits into from
Mar 17, 2023
Merged

Conversation

hmuurine
Copy link
Collaborator

Summary

Added some Unit tests for the library project:

  • Added Jest dependencies and configuration for running unit tests with npm run test
  • Added initial unit tests for the public API:
    • Config: test setting & getting configuration, initial settings, persisting data to URL
    • AFKController: test that AFK timers and events work as expected
    • PixelStreaming: test mocked WebSocket connection, mocked WebRTC connection, mocked video playback, events emitted in various stages of the connection process, statistics emitter, data channel send/receive
  • Mocks for WebSocket, MediaStream and WebRTC classes that are not natively supported in Jest/Node/jsdom test environment

Test Plan

  • Ran the unit tests and verified that they worked
  • Broke some of the functionality deliberately and verified that this was caught in unit tests

@vshjxyz
Copy link

vshjxyz commented Mar 15, 2023

Huge one! That's awesome, we should leverage (if possible) having a public repo to integrate coverage reports into PRs to keep track and avoid merging PRs without enough coverage. Since this is a library aimed to be consumed by multiple clients that can also help on external contributions, but I'm probably thinking too far ahead (?)

@lukehb
Copy link
Contributor

lukehb commented Mar 16, 2023

Amazing PR! Great work.

A few additional requests on top of the comments I have already left:

  1. Can it also include a github action for running these tests against PRs that touch the Frontend/library files?
  2. Can you update frontend readme.md informing users how to run these tests by hand.

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

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

Left some minor comments.

@hmuurine
Copy link
Collaborator Author

1. Can it also include a github action for running these tests against PRs that touch the Frontend/library files?

Added an action that runs the unit tests if Frontend/library/** files change. The action is run for master commits and all PRs that have target branch master. You can see the actions triggered already in this PR. Also tested that test failures are properly detected:
Screenshot 2023-03-16 at 15 43 27

2. Can you update frontend readme.md informing users how to run these tests by hand.

Done in a1c9f46

Copy link
Contributor

@lukehb lukehb left a comment

Choose a reason for hiding this comment

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

lgtm!

@lukehb lukehb merged commit f58b32c into EpicGames:master Mar 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants