-
Notifications
You must be signed in to change notification settings - Fork 190
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
Enhance react integration test #2389
base: main
Are you sure you want to change the base?
Conversation
ea668a0
to
8f2994c
Compare
|
||
describe("Empty state user flow", () => { | ||
|
||
let mockWinOpenFunc: jest.Mock; |
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.
/nit As someone looking at this with no context, the function name isn't super clear. Does it mean mockWindowOpenFunc
?
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.
have abstracted it away
} | ||
|
||
async function clickButton(buttonText: string) { | ||
await act(async() => { |
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.
It would be good to move these to a different file to allow them to be reused more globally or moved directly into the test case if they won't be reused at all
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.
Yup have moved it in a utils file.
} | ||
|
||
function expectUserLoginSuccess(login: string) { | ||
expect(screen.queryByText("Select your GitHub product")).not.toBeInTheDocument(); |
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 have a personal preference for not adding assertions in a function, because it may be confusing to someone writing test cases if a "hidden" assertion fails. Would love to hear more about your opinion on this @gxueatlassian
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.
My idea is the treat expectUserLoginSuccess
as any other expectXXX
.
If a "hidden" assertion fail, dev shouldn't be confused that something fail inside expectUserLoginSuccess
, although dev still need to look inside to see what's failing.
I am keen to keep this as it is, but I can change it if you strongly suggest should use plain expect.I am also okay with that.
@@ -0,0 +1 @@ | |||
module.exports = {}; |
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.
In some react component we use import xxx.css
.
Seems the OrgsContainer
we import ScrollBar which import SimpleBar which import xx.css
and ts-jest is failing on recongise it.
Search web give me answer that to put a stub here just to pase the ts check.
@@ -3,6 +3,9 @@ | |||
"transform": { | |||
"^.+\\.tsx?$": "ts-jest" | |||
}, | |||
"moduleNameMapper": { | |||
"^.+\\.css$": "<rootDir>/css.stub.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.
Same as above.
@@ -1,4 +1,3 @@ | |||
import "@testing-library/jest-dom"; |
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.
To speed up the test coz we don't need it in each file, just the setup.ts file.
@@ -22,5 +23,5 @@ | |||
"rest-interfaces": ["./src/rest-interfaces"] | |||
} | |||
}, | |||
"include": ["src"] | |||
"includes": [ "./setup.ts", "src" ] |
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.
Otherwise doesn't looks like the ts-jest is including the tesing-lib/js-dom thing during the ts compile phase.
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 mean after I remove import "@testing-library/jest-dom";
tests failed, turns out that import "@testing-library/jest-dom";
is not called by ts-jest during compile.
ps: is has nothing to do with jest at compile time.
Pull request was converted to draft
What's in this PR?
Enhance the react integration test.
Why
Added feature flags
Affected issues
N/A
How has this been tested?
Integration Test
Whats Next?