-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spike: Running Mounted LB3 App Tests #5251
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
Conversation
|
Thank you @nabdelgadir for looking into ways how to run tests of a LB3 app from inside LB4! I'll try to review the proposal tomorrow 🤞 |
cd2fec6 to
ff8902f
Compare
bajtos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the proposed design 👍
Let's polish the details now and make sure the migration requires as little changes in the original test code as possible. A typical application can have dozens of test files with hundreds of tests, every additional step would create a lot of work for our users.
| user, | ||
| ) { | ||
| user.email.should.be.equal('new@email.com'); | ||
| json('post', '/api/users/login') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please find a way how to allow this test to call User.login directly via JavaScript API, so that users don't have to rework all their tests calling model API from JavaScript to make HTTP requests instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this perhaps trying to workaround the problem that User has unknown type? (See the discussion below.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC...I think Nora tests the endpoint instead of the API here because it's acceptance test :p The APIs are tested in the integration test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize now this file is a bit confusing because I was trying to mimic the original acceptance tests which makes this now acceptance + integration but I think I'll put the auth tests in their own file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my point of view: this acceptance test has two parts. In the first part, we want to setup data (e.g. User instance, a valid AccessToken, etc.). In the second part, we test the actual scenario.
I am arguing that for test setup, we should use the most performant solution. This part is not testing anything, it's just preparing data to enable the scenario being tested. That's why I prefer to call model methods directly via JS API. HTTP calls introduce non-negligible slow down.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am arguing that for test setup, we should use the most performant solution. This part is not testing anything, it's just preparing data to enable the scenario being tested. That's why I prefer to call model methods directly via JS API. HTTP calls introduce non-negligible slow down.
Oh I see, thanks for explanation 👍
ff8902f to
5744661
Compare
jannyHou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 Very useful guide and good job of the spike! Mostly LGTM, a few suggestions.
| "eslint:fix": "npm run eslint -- --fix", | ||
| "pretest": "npm run build", | ||
| "test": "lb-mocha \"dist/__tests__/**/*.js\"", | ||
| "test": "lb-mocha \"dist/__tests__/**/*.js\" \"lb3app/test/*.js\"", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
|
||
| let app; | ||
|
|
||
| function json(verb, url) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: the function name is a bit confusing, maybe call it as setContentType?
And why the test has to set the content type and Accept as application/json then send the payload? Is it also part of the migration guide?
(hmm, "migration" may not be the accurate word haha)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was traditional lb3 naming because it's what I've seen in lb3 examples (like here and here) 🙈
And why the test has to set the content type and Accept as application/json then send the payload? Is it also part of the migration guide?
Since we want users to change as little code as possible, I maintained the function as is, but I agree we can rename the function name 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to request to match what the function does; what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, I didn't realize it's from LB3...then I am ok to keep the name as it is. Since it's migration.
5744661 to
d05de35
Compare
bajtos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new version looks pretty good! I have few minor comments to consider, see below.
I don't want to block progress, feel free to land the changes after getting approval from @jannyHou, no need to wait for me.
packages/booter-lb3app/src/__tests__/acceptance/booter-lb3app.acceptance.ts
Outdated
Show resolved
Hide resolved
0eb9c17 to
59621e7
Compare
59621e7 to
a823ca8
Compare
jannyHou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
|
Created followup stories:
These two should be completed after the first one:
Closing the spike as done. |
Related to #5004.
Proposal for running acceptance and integration tests. Details can be found in SPIKE.md.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm testpasses on your machinepackages/cliwere updatedexamples/*were updated👉 Check out how to submit a PR 👈