-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[Testing] Improve testing capabilities for Web #521
Merged
Merged
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d1c0b50
feat(testing): add testing package
RobertBroersma a800bd2
fix(core): configure jest to work nicely with testing package
RobertBroersma 82dad34
Apply suggestions from code review
RobertBroersma e91dd44
Include router mock in testing package
RobertBroersma d57e587
Merge remote-tracking branch 'origin/rb-testing' into rb-testing
RobertBroersma 7b86ca9
Rely on dynamic import instead of weird import and add some comments
RobertBroersma f8a6728
Merge branch 'master' into rb-testing
RobertBroersma 9b36d4a
Replace MockedProvider in render by doc explaining how to mock
RobertBroersma 1ae2a66
Convert routes-auto-loader to Babel plugin
RobertBroersma a9c92c5
Move fileMock to testing package
RobertBroersma 22dcc46
Add README.md according to new guidelines
RobertBroersma b2e4aff
Merge branch 'master' into rb-testing
RobertBroersma 482ee70
Update and resolve @types/react and @types/react-dom
RobertBroersma 0440885
Simplify import string
RobertBroersma 95b6ef6
But with the .routes of course
RobertBroersma 3e34a4b
And without the src
RobertBroersma c22124d
Merge branch 'master' into rb-testing
RobertBroersma f1587ca
Merge branch 'master' into rb-testing
RobertBroersma e57a239
Rename routerMock and implement all exports.
peterp 0924992
Mock router.
peterp c112004
Add a description.
peterp a25e05a
Remove Apollo Mock export.
peterp abcfbd2
Add comments.
peterp 9ecba60
Remove testing-library imports.
peterp edbac9e
Update README.
peterp 3637d5c
Fix tests.
peterp 5ea27e3
Merge pull request #1 from redwoodjs/rb-testing
RobertBroersma 55b6ca4
Merge branch 'master' into rb-testing
peterp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'fileMock' | ||
RobertBroersma marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { extends: '../../babel.config.js' } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@redwoodjs/testing", | ||
"version": "0.6.0", | ||
"files": [ | ||
"dist" | ||
], | ||
"main": "dist/index.js", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@redwoodjs/router": "^0.6.0", | ||
"react": "*" | ||
}, | ||
"dependencies": { | ||
"@apollo/react-testing": "^3.1.4", | ||
"@redwoodjs/web": "^0.6.0", | ||
"@testing-library/react": "^10.0.4" | ||
}, | ||
"scripts": { | ||
"build": "yarn cross-env NODE_ENV=production babel src -d dist --delete-dir-on-start --extensions \".js,.ts\" --source-maps inline" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from '@testing-library/react' | ||
|
||
export { customRender as render } from './render' | ||
RobertBroersma marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import { MockedProvider } from '@apollo/react-testing' | ||
|
||
import Routes from '~/web/Routes' | ||
RobertBroersma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const AllTheProviders = ({ mocks, children }) => { | ||
return ( | ||
<MockedProvider mocks={mocks} addTypename={false}> | ||
RobertBroersma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<> | ||
<Routes /> | ||
{children} | ||
</> | ||
</MockedProvider> | ||
) | ||
} | ||
|
||
export const customRender = (ui, options = {}) => | ||
render(ui, { | ||
wrapper: (props) => <AllTheProviders mocks={options.mocks} {...props} />, | ||
...options, | ||
}) | ||
RobertBroersma marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you think this file could be part of
@redwoodjs/testing
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 think it could. Do you think it would be a good idea to move other testing stuff like Jest config and the setup files to that
@redwoodjs/testing
as well? And have the testing package sort of dogfood the rest of the monorepo?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 would like to keep configuration in core. In my mind the "core" package is what a user's requires to develop and build a redwood project and the configurations are part of that.
The file mock feels like something that should belong to test, whereas this configuration is something that's using "@redwoodjs/testing" - that distinction may seem a bit loosey-goosey and I'll try to clarify it with better language.