-
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
Standard /web Tests Fail #265
Comments
I should add that I think I can probably handle this but would love a nudge in the right direction. For an idea in what I've tried (that didn't work), I thought it may have been the |
@AryanJ-NYC grateful for your help here! So bummed the tests are failing spectacularly. Welcome to my own person config nightmare 😉 For the record, it’s good for the sanity to not go it alone. We’ll figure this out! (With some help from @peterp as well.) I don’t have time for a full deep dive today, but I can attempt to provide some background. We handle
If you look at the file Thoughts on currently failing testsI stepped through the Tutorial up to the point of “A Second Page and a Link” to see when the errors start showing up. And as soon as I did, I’m also getting the I think our Webpack import settings have not been correctly (or fully) applied to the Babel config used by Jest. Where I’d start to diagnose is spending time with Webpack to see what else might be missing. Also, no need to beat your head against this if things aren’t budging. Simply running the tests and reporting issues is a great start for us! |
@peterp here’s my code attempt to fix const path = require('path')
const { getPaths } = require(‘@redwoodjs/internal')
module.exports = {
resolver: 'jest-directory-named-resolver',
rootDir: path.join(getPaths().base, 'web'),
} Runs tests but same type error:
|
Current fix in process is happening in this PR #290 |
Closed by #290 |
Re-opening this as tests are still failing. I could be wrong here, but I believe #290 was the config we needed in order to proceed, however we still have some steps to get tests working. (See next comments.) |
Ah yeah. We need to change the way |
My local setup is using Passing template tests
Failing vanilla template tests with output1. ServicesUsing the FAIL src/services/posts/posts.test.js
● Test suite failed to run
Cannot find module '/Users/price/Repos/xx-redwoodblog/api/src/config/db' from 'posts.js'
However, Jest was able to find:
'./posts.js'
'./posts.test.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'json', 'jsx', 'ts', 'tsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
9 | }
10 |
> 11 | export const createPost = ({ input }) => {
| ^
12 | return db.post.create({
13 | data: input,
14 | })
at Resolver.resolveModule (../node_modules/jest-resolve/build/index.js:276:11)
at Object.<anonymous> (src/services/posts/posts.js:11:11) 2. CellsUsing FAIL src/components/BlogPostsCell/BlogPostsCell.test.js
● Console
console.error ../node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Uncaught [Error: Success(...): Nothing was returned from render. This usually means a return statement is missing. Or,
to render nothing, return null.]
...
● BlogPostsCell › Success renders successfully
Success(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return
null.
25 |
26 | it('Success renders successfully', () => {
> 27 | render(
| ^
28 | <Success userExample={{ blogPosts: { objectKey: 'objectValue' } }} />
29 | )
30 | expect(
... Failing tutorial tests with output3. PagesWhen adding routes/links to pages (as in the tutorial for Home and About), we run into and issue with Jest not having access to the ‘routes’ object. We’ll likely need to mock the routes object ourselves because it’s dynamically generated. Current test fail output for Error: Uncaught [TypeError: _router.routes.about is not a function]
at reportException (/Users/price/Repos/xx-redwoodblog/node_modules/jsdom/lib/jsdom/living/helpers
/runtime-script-errors.js:62:24)
…
HomePage › renders successfully
expect(received).not.toThrow()
Error name: "TypeError"
Error message: "_router.routes.about is not a function"
9 | <ul>
10 | <li>
> 11 | <Link to={routes.about()}>About</Link>
| ^
12 | </li>
13 | </ul>
14 | </nav>
... |
Hey @thedavidprice , just logging here that importing images as the example below also causes the tests to fail. Are you guys planning on adding a generic mock for media assets via
|
Hey! First of all, great job with Redwood. This definitely has tons of potential and I'd love to help out in any way I could.
In messing with #256, I just couldn't seem to get the
/web
tests to pass with the app built from the tutorial. I would get:for just about every test.
Here are some steps to reproduce:
git clone https://github.com/AryanJ-NYC/redwoodjsblogexample
yarn install && yarn rw db generate && yarn rw test web
The text was updated successfully, but these errors were encountered: