- Notifications
You must be signed in to change notification settings - Fork 3
E2e tests #233
E2e tests #233
Conversation
tests/joke.test.ts Outdated
| test('jokes.byCategory should return a random joke', async () => { | ||
| const response = await client().query({ | ||
| query: gql` | ||
| query Query { |
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 change the operation name to something more descriptive e.g. GeRandomJokesByCategory
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.
Fixed.
tests/client.ts Outdated
| global['fetch'] = fetch; | ||
| | ||
| const httpLink = new HttpLink({ | ||
| uri: `${process.env.E2E_TEST_URI}/${process.env.GRAPHQL_PATH}`, |
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.
pls change to E2E_TEST_URL to stay consistent with SELF_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.
You mean to rename the variable to E2E_TEST_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.
yes
jest/e2e.config.js Outdated
| { | ||
| "testRegex": ".*\\.test\\.(ts)$", | ||
| "roots": [ | ||
| "tests" |
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.
change to e2e ?
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.
Changed both the folder name and the suffix.
package.json Outdated
| "@types/koa": "2.0.45", | ||
| "@types/koa-router": "7.0.27", | ||
| "@types/nock": "9.1.3", | ||
| "apollo-cache-inmemory": "^1.1.12", |
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 use the exact versions
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.
Fixed.
src/env.ts Outdated
| CORS: bool({ devDefault: true, default: false }), | ||
| LOG_LEVEL: str({ default: 'info' }), | ||
| LIVENESS_PATH: str({ default: 'healthz' }), | ||
| E2E_TEST_URI: str({ default: 'http://localhost:3001' }), |
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's keep the app env and the e2e test env variable sets separate
please move this to a different module, e.g. jest/test-env.ts and add to the jest setup files
tests/client.ts Outdated
| | ||
| const httpLink = new HttpLink({ | ||
| uri: `${process.env.E2E_TEST_URI}/${process.env.GRAPHQL_PATH}`, | ||
| credentials: 'include', |
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.
why?
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.
Not needed and removed.
tests/client.ts Outdated
| import { ApolloClient } from 'apollo-client'; | ||
| import { HttpLink } from 'apollo-link-http'; | ||
| import { InMemoryCache } from 'apollo-cache-inmemory'; | ||
| import gql from 'graphql-tag'; |
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.
if your intention for importing gql is to simply re-export, you can do that explicitly:
export {default as gql} from 'graphql-tag'
although I don't see a reason for not importing it in the test directly, what difference does it make?
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've done it this way because I find it more convenient to import these two things from a single place when writing tests.
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.
k
tests/client.ts Outdated
| import gql from 'graphql-tag'; | ||
| import fetch from 'node-fetch'; | ||
| | ||
| global['fetch'] = 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.
both statements can be removed with just import 'isomorphic-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.
Wonderful! Fixed.
jest/e2e.config.js Outdated
| { | ||
| "testRegex": ".*\\.test\\.(ts)$", | ||
| "roots": [ | ||
| "tests" |
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.
aslo add to include array in tsconfig.json
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.
What for?
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 IDE will not use our root tsconfig.json
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, done.
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.
Hm, this changed broke compilation. Not sure what the problem is.
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 will take a look later
README.md Outdated
| | ||
| ### Run e2e tests | ||
| | ||
| Run the app or point E2E_TEST_URI to a remote instance you want to test against. |
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 change to E2E_TEST_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.
Done.
Fixes #232