Giter Club home page Giter Club logo

Comments (7)

cadlagtrader avatar cadlagtrader commented on May 27, 2024 1

Hello @dac09 - thanks for looking into it!

Using your project and yarn rw test web

  • no error when i run from a system terminal
  • same error when running from vscode terminal

I have tried to remove all launch configuration + all extensions in vscode, still hitting the same error. Both terminals are using zsh and node 20 installed through nvm

It seems @redwoodjs/auth module is not loaded properly (only useAuth and createAuthentication are available in the watcher). Just to confirm, I only see the issue with rw>=7.4. Could it be the new esm/cjs change ?

from redwood.

cadlagtrader avatar cadlagtrader commented on May 27, 2024 1

OK, so my mistake🙈: I was using my test project, not yours when testing in vscode (they are similar except for this RedwoodApolloProvder wrapping the HomePage).
So now vscode and the terminal are consistent.

The issue boils down to the RedwoodApolloProvider we instantiate in a TestWrapper for several of our tests. I had added it to my test project to isolate the issue.

When I add the same to your test project, I get the same error stack including the error message below

Error name:    "TypeError"
Error message: "useAuth is not a function"

So the bifurcation is: when RedwoodApolloProvider is invoked either in a jest TestWrapper or inside a test without a useAuth prop:
-RW<7.4 is fine with no prop for useAuth
-RW>=7.4 fails because useNoAuth in undefined

This is not a blocking issue for us as I can set the useAuth of RedwoodApolloProvider to the useAuth implementation of our auth provider in my tests

Thanks!

from redwood.

Tobbe avatar Tobbe commented on May 27, 2024

Thanks for your issue report. Without any way to reproduce this it's going to be difficult to find a fix unfortunately. But I'll definitely keep this in mind if more issues like this starts popping up

from redwood.

cadlagtrader avatar cadlagtrader commented on May 27, 2024

Hi @Tobbe, I think I narrowed down the issue.
RedwoodApolloProvider has a default for useAuth = _auth.useNoAuth. Somehow this default is not working anymore.
I have added the steps to reproduce above

from redwood.

dac09 avatar dac09 commented on May 27, 2024

Hey @cadlagtrader - thanks for the issue and the steps!

So I followed your steps -

  1. created new project
  2. setup dbAuth yarn rw setup auth dbAuth
  3. generated homepage yarn rw g HomePage /
  4. ran web unit tests yarn rw test web and yarn rw test web --no-watch

Version i used is : "7.4.3"

but don't really see an error ☹️. I have the project pushed up here: https://github.com/dac09/useauth-jest-debug

Suggestions to try:

  • see if you can reproduce the issue in my project above. If you can't it might be something specific to your project
  • remove and reinstall all node_modules, and see if the problem persists (basically turn it off and on again 🤣)
  • if you're still encountering issues could you please PR into my repo, or create a new one so we can debug a little better!

from redwood.

dac09 avatar dac09 commented on May 27, 2024

Heyooo, so I tried the same thing in both vscode terminal (zsh also) - and the javascript debugger terminal, still can't see it error out!

For reference I'm using Volta, and tried Node v20.10.10 and v20.12.2, and v20.11.1 to check.

Could totally be the esm/cjs change (kind of has to be!). There's a little hint in your screenshot too, where it says __esModule: true. Trying to understand why it might be picking up esm instead of cjs.


I just noticed you had an extra step here:

> render(
>        <RedwoodApolloProvider>
>          <HomePage />
>        </RedwoodApolloProvider>
>      )

I get all sorts of errors after I did this. Imported from import { RedwoodApolloProvider } from '@redwoodjs/web/apollo'

  • When you got the error, did you change the test also? Or just left the render as is?
  • Could you help me understand why you're wrapping in ApolloProvider?
  • Where is RedwoodApolloProvider imported from? This could tell us where this esm stuff is coming from!

from redwood.

dac09 avatar dac09 commented on May 27, 2024

Thanks for getting back and the break down @cadlagtrader ✌️✌️✌️

I'm closing the issue as there is a resolution in your comment here: #10500 (comment)

if anyone else comes across this again, or would like to help debug further please feel free to comment and we can reopen the issue.

from redwood.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.