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

End to end test example #75

Merged
merged 8 commits into from
Jan 30, 2024
Merged

End to end test example #75

merged 8 commits into from
Jan 30, 2024

Conversation

slinkydeveloper
Copy link
Contributor

Copy link
Collaborator

@gvdongen gvdongen left a comment

Choose a reason for hiding this comment

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

Looks good, will be a nice addition! I think we can make it slightly easier to be replicated by having two files for the testing logic: one to copy over with the logic of setting everything up (later to be put into an npm package), and one which just shows a single test that then uses the setup. What do you think?
Also, can we add an example for the handler API as well?

typescript/end-to-end-testing/test/test.ts Outdated Show resolved Hide resolved
typescript/end-to-end-testing/test/test.ts Show resolved Hide resolved
@slinkydeveloper
Copy link
Contributor Author

Also, can we add an example for the handler API as well?

Can I do this in a followup?

Copy link
Collaborator

@gvdongen gvdongen left a comment

Choose a reason for hiding this comment

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

Thanks for splitting up! Much nicer now.
I get the following error when running npm run test

 FAIL  test/test.ts
  ● ExampleService › works

    Error 404 during registration:

      79 |     if (!res.ok) {
      80 |       const badResponse = await res.text();
    > 81 |       throw new Error(
         |             ^
      82 |         `Error ${res.status} during registration: ${badResponse}`
      83 |       );
      84 |     }

      at prepareRestateTestContainer (test/restate_test_environment.ts:81:13)
      at Function.start (test/restate_test_environment.ts:121:35)
      at Object.<anonymous> (test/test.ts:15:30)


  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'stop')

      31 |   // Stop Restate and the Service endpoint
      32 |   afterAll(async () => {
    > 33 |     await restateTestEnvironment.stop();
         |                                  ^
      34 |   });
      35 |
      36 |   it("works", async () => {

      at Object.<anonymous> (test/test.ts:33:34)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        3.987 s, estimated 6 s
Ran all test suites.

Jest has detected the following 1 open handle potentially keeping Jest from exiting:

  ●  TCPSERVERWRAP

      22 |   await new Promise((resolve, reject) => {
      23 |     restateHttpServer
    > 24 |       .listen(0)
         |        ^
      25 |       .once("listening", resolve)
      26 |       .once("error", reject);
      27 |   });

      at test/restate_test_environment.ts:24:8
      at prepareRestateServer (test/restate_test_environment.ts:22:9)
      at Function.start (test/restate_test_environment.ts:120:42)
      at Object.<anonymous> (test/test.ts:15:59)

README.md Outdated Show resolved Hide resolved
typescript/end-to-end-testing/README.md Outdated Show resolved Hide resolved
typescript/end-to-end-testing/README.md Outdated Show resolved Hide resolved
@slinkydeveloper
Copy link
Contributor Author

Error 404 during registration:

Perhaps you have an old image?

@gvdongen
Copy link
Collaborator

@slinkydeveloper That was indeed the issue.
Should we just for sake of documentation add this to the readme? Something like:

If you are encountering errors, try to do `docker pull docker.io/restatedev/restate:latest`.

I guess if I bump into this, I am not the only one.

@gvdongen
Copy link
Collaborator

LGTM!

@slinkydeveloper slinkydeveloper merged commit 112afcc into main Jan 30, 2024
2 checks passed
@slinkydeveloper slinkydeveloper deleted the end-to-end-test-example branch January 30, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants