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

add browser tck test suite #212

Open
wants to merge 10 commits into
base: 1.0.x
Choose a base branch
from
Open

add browser tck test suite #212

wants to merge 10 commits into from

Conversation

viglucci
Copy link
Member

@viglucci viglucci commented Jan 23, 2022

Adds a test suite that exercises various @rsocket packages and patterns to ensure compatibility with Browser environments. This is done by compiling the actual test files into a browser-compatible version, and executing the test suite from within a browser context using Karma.

The suite is intended to run on all pushes and PR's, though you'll notice there are browser compatibility issues with various RSocket APIs, so the suite currently fails. In addition to the initial tests added in this PR, there are likely other APIs with browser compatibility issues (really anywhere Buffer is used) that will need to ultimately be covered as well.

Example test output:

23 01 2022 00:00:00.936:INFO [compiler.karma-typescript]: Compiling project using Typescript 4.5.4
23 01 2022 00:00:06.766:INFO [compiler.karma-typescript]: Compiled 1 files in 5816 ms.
23 01 2022 00:00:07.674:INFO [bundler.karma-typescript]: Bundled imports for 1 file(s) in 408 ms.
23 01 2022 00:00:07.677:INFO [karma-server]: Karma v6.3.11 server started at http://localhost:9876/
23 01 2022 00:00:07.677:INFO [launcher]: Launching browsers ChromeHeadlessCI with concurrency unlimited
23 01 2022 00:00:07.692:INFO [launcher]: Starting browser ChromeHeadless
23 01 2022 00:00:07.986:INFO [Chrome Headless 98.0.4758.0 (Linux x86_64)]: Connected on socket QAqP7-lVctYze3jsAAAB with id 94968735
  CompositeMetadata
    ✖ encodeRoute
    ✖ encodeCompositeMetadata

Finished in 0.002 secs / 0.001 secs @ 00:00:08 GMT+0000 (Coordinated Universal Time)

SUMMARY:
✔ 0 tests completed
✖ 2 tests failed

FAILED TESTS:
  CompositeMetadata
    ✖ encodeRoute
      Chrome Headless 98.0.4758.0 (Linux x86_64)
    ReferenceError: Buffer is not defined
        at encodeRoute (/tmp/karma-typescript-bundle--778-pAzoKp0HW4d1-.js:452:24)
        at Context.<anonymous> (src/CompositeMetadata.spec.ts:15:37 <- src/CompositeMetadata.spec.js:8:65)

    ✖ encodeCompositeMetadata
      Chrome Headless 98.0.4758.0 (Linux x86_64)
    ReferenceError: Buffer is not defined
        at encodeCompositeMetadata (/tmp/karma-typescript-bundle--778-pAzoKp0HW4d1-.js:7689:36)
        at Context.<anonymous> (src/CompositeMetadata.spec.ts:21:52 <- src/CompositeMetadata.spec.js:13:80)

@viglucci viglucci added the 1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release label Jan 23, 2022
@viglucci viglucci marked this pull request as ready for review January 24, 2022 04:36
@@ -14,6 +14,7 @@
"test": "yarn jest"
},
"devDependencies": {
"@types/jest": "^27.0.3",
Copy link
Member Author

@viglucci viglucci Jan 24, 2022

Choose a reason for hiding this comment

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

jest and mocha have conflicting type definitions that cause issues when compiling with karma-typescript, which we can overcome by moving the @types/jest into the dependencies list of the individual packages, and telling yarn workspaces not to house the types as well so that they are not discovered by typescript when compiling in the new browser-tck package.

This would be less of an issue if we used jest in the browser-tck as well, but there is complications getting Jest to run in a browser, such as needing to provide a bunch of pollyfills, so using mocha was a bit simpler there.

@OlegDokuka
Copy link
Member

I expect that for browser env folks will be importing any buffer polyfill. Thus, should we add from the browser test dependency?

@viglucci
Copy link
Member Author

viglucci commented Jan 24, 2022

My hope has been that we can support supplying a polyfill through the public API, via optional constructor dependency injection, or other DI pattern (like how we support WebSocket factory on the WS client transport).

Most front-end build tools support polyfilling an API globally, but it varies by tool, and is often confusing for new users. So my goal would be to offer browser support directly, rather than require global polyfill.

@viglucci viglucci changed the title (draft) test/browser tck add browser tck test suite Jan 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 Pullrequests & issues related to the Typescript rewrite and 1.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants