-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Grid UI Unit Tests #8865
Grid UI Unit Tests #8865
Conversation
javascript/grid-ui/jest.config.js
Outdated
"<rootDir>/src" | ||
], | ||
testMatch: [ | ||
"<rootDir>/src/tests/*.test.ts", |
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.
"<rootDir>/src/tests/*.test.ts", | |
"<rootDir>/src/tests/*.test.ts", | |
"<rootDir>/src/tests/*.test.tsx", |
@@ -0,0 +1,30 @@ | |||
import * as React from 'react'; |
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.
rename this file so that it ends with tsx
instead of ts
@@ -0,0 +1,15 @@ | |||
import * as React from 'react'; |
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.
rename this file so that it ends with tsx
instead of ts
}, { | ||
isChecked: boolean | ||
}> { | ||
constructor(props) { |
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.
constructor(props) { | |
constructor(props: any) { |
6504624
to
de70765
Compare
javascript/grid-ui/package.json
Outdated
@@ -61,5 +61,19 @@ | |||
"last 1 firefox version", | |||
"last 1 safari version" | |||
] | |||
}, | |||
"devDependencies": { |
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.
All of these need to be at the to be in the top level package.json
file in the root of the repo
javascript/grid-ui/BUILD.bazel
Outdated
"jest.config.js" | ||
], | ||
data = [ | ||
"//:jest.config.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.
By having //
you're telling it to look at the root of the repo which means it will error.
javascript/grid-ui/BUILD.bazel
Outdated
"--ci", | ||
"--colors", | ||
"--config", | ||
"jest.config.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.
"jest.config.js" | |
"$(location jest.config.js)" |
That will find it local to the bazel build
2f66ac0
to
4ed5897
Compare
javascript/grid-ui/src/setupTests.ts
Outdated
@@ -0,0 +1,3 @@ | |||
import { configure } from 'enzyme'; |
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.
This file should probably be a .tsx
file so we don't get that weird issue we had before
jest.config.js
Outdated
@@ -0,0 +1,19 @@ | |||
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.
We don't need this file, we can use the one that is in the grid-ui directory
javascript/grid-ui/src/App.tsx
Outdated
@@ -21,6 +22,7 @@ import NodeType from "./models/node"; | |||
const cache = new InMemoryCache(); | |||
const link = new HttpLink({ | |||
uri: GridConfig.serverUri, | |||
fetch |
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 line needed? It feels like this would error since it's not in an object format
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.
Yes, its needed.
There are some tests that fail with the following message:
Test suite failed to run
Invariant Violation:
fetch is not found globally and no fetcher passed, to fix pass a fetch for
your environment like https://www.npmjs.com/package/unfetch.
For example:
import fetch from 'unfetch';
import { createHttpLink } from 'apollo-link-http';
const link = createHttpLink({ uri: '/graphql', fetch: fetch });
20 |
21 | const cache = new InMemoryCache();
> 22 | const link = new HttpLink({
| ^
23 | uri: GridConfig.serverUri,
24 | });
25 |
at new InvariantError (../../../../../../../../../node_modules/ts-invariant/lib/invariant.esm.js:12:28)
at Object.<anonymous>.exports.checkFetcher (../../../../../../../../../node_modules/apollo-link-http-common/src/index.ts:178:11)
at Object.<anonymous>.exports.createHttpLink (../../../../../../../../../node_modules/apollo-link-http/src/httpLink.ts:46:3)
at new HttpLink (../../../../../../../../../node_modules/apollo-link-http/src/httpLink.ts:259:11)
at Object.<anonymous> (../../../../src/App.tsx:22:14)
at Object.<anonymous> (../../../../src/core/Status.ts:2:1)
at Object.<anonymous> (../../../../src/screens/Console/Console.tsx:14:1)
at Object.<anonymous> (../../../../src/screens/Console/Console.keybinds.ts:4:1)
at Object.<anonymous> (../../../../src/components/KeyBoard/KeyBoardHelp.tsx:7:1)
at Object.<anonymous> (../../../../src/components/NavBar/NavBar.tsx:12:1)
at Object.<anonymous> (../../../../src/tests/components/NavBar.test.tsx:3:1)
When checked on SO, that was the fix that was suggested on multiple questions of similar error stack trace.
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 able to build and start the server. UI page opens fine.
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.
Ok, can we have it as a key/value pair then
javascript/grid-ui/BUILD.bazel
Outdated
"--ci", | ||
"--colors", | ||
"--config", | ||
"$(rootpath jest.config.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.
"$(rootpath jest.config.js)" | |
"$(location jest.config.js)" |
4ed5897
to
3c0535e
Compare
Co-authored-by: David Burns <david.burns@theautomatedtester.co.uk>
Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it
Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.
Description
Motivation and Context
Types of changes
Checklist