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

test: Make node integration test runner more resilient #14245

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Nov 12, 2024

Noticed while debugging some test problems, that if axios throws an error (e.g. you get a 500 error), jest cannot serialize the error because it contains recursive data, leading to super hard to debug error messages.

This makes our node integration test runner more resilient by normalizing errors we get there to ensure circular references are resolved.

Update

While working on this, I found some further, actually more serious problems - some tests were simply not running at all. Especially all the session aggregrate tests were simply not being run and just "passed" accidentally.

The core problem there was that the path to the scenario was incorrect, so nothing was even started, plus some things where we seemed to catch errors and still pass (?? I do not think I fixed all of the issues there, but at least some of them...)

Now, we assert that the scenario file actually exists. Plus, instead of setting .expectError() on the whole runner, you now have to pass this to a specific makeRequest call as an optional option, and it will also assert if we expect an error but do not get one. This way, the tests can be more explicit and clear in what they do.

@mydea mydea requested review from timfish and Lms24 November 12, 2024 12:27
@mydea mydea self-assigned this Nov 12, 2024
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

This is great, thanks! I also noticed this error before and had no idea where it came from.

@mydea
Copy link
Member Author

mydea commented Nov 13, 2024

Update on this:

While working on this, I found some further, actually more serious problems - some tests were simply not running at all. Especially all the session aggregrate tests were simply not being run and just "passed" accidentally.

The core problem there was that the path to the scenario was incorrect, so nothing was even started, plus some things where we seemed to catch errors and still pass (?? I do not think I fixed all of the issues there, but at least some of them...)

Now, we assert that the scenario file actually exists. Plus, instead of setting .expectError() on the whole runner, you now have to pass this to a specific makeRequest call as an optional option, and it will also assert if we expect an error but do not get one. This way, the tests can be more explicit and clear in what they do.

});

const runner = createRunner(__dirname, 'server.ts')
test('should aggregate successful and crashed sessions', done => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This and the other tests below were simply not doing anything at all, if you look through it in detail you see a bunch of things that can't work:

  1. the path to the server.ts is wrong
  2. The route paths are wrong

@@ -52,4 +50,4 @@ app.get('/test/error_handled', (_req, res) => {

Sentry.setupExpressErrorHandler(app);

export default app;
startExpressServerAndSendPortToRunner(app);
Copy link
Member Author

Choose a reason for hiding this comment

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

Also this scenario file could not work at all and needed adjustment.

@@ -1,5 +0,0 @@
import express from 'express';
Copy link
Member Author

Choose a reason for hiding this comment

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

This was not actually used anymore anwhere.

Copy link
Member

@Lms24 Lms24 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 fixing these!

@mydea mydea merged commit 335da37 into develop Nov 13, 2024
123 checks passed
@mydea mydea deleted the fn/node-test-runner branch November 13, 2024 09:33
mydea added a commit that referenced this pull request Nov 13, 2024
Oops, #14245 broke
our remix integration tests.

Instead of re-exporting this from a path (which is not resolved nicely
etc. and not reflected by our dependency graph) we can just inline the
two methods we need here, they are not too complicated.
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.

3 participants