Git Product home page Git Product logo

Comments (12)

prescottprue avatar prescottprue commented on June 3, 2024 1

Sure! Glad to help!

It looks like your file path has a space in it - could you try escaping it by putting a \ in front of that? Seems like the original example did as well.

cypress-firebase should definitely handle this case internally, but just want to see if that helps

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024 1

I found a workaround, and this way works --

cy.tokenLoginAs("admin")
      .log("Creating test case...")
      .writeFile(testCaseFixturePath, testCase)
      .then(() => {
        cy.callFirestore("set", getTestCaseDocPath("admin", testCase._id), testCaseFixtureName)
        .as("testCaseCreated")
        .log("Test Case created.")
      })

Then in after(), I delete the file and the database item.

So I know that this error is simply because of the path.

Also, I have now tried npx, and that works great for me.

from cypress-firebase.

prescottprue avatar prescottprue commented on June 3, 2024

Hmm... Yarn shouldn't impact the npm bin.

Do you have firebase-tools installed within your project? It is a peer-dependency as it is needed to run commands with admin privileges.

I haven't really seen this before, and not sure why it wouldn't be parsing that as expected. In the past npx was used, so I may look into switching back to that instead of a command containing the bin reference.

Have you tried using get in callFirestore? Does it also produce a similar error for you?

Just so I can try replicating - which version of cypress, cypress-firebase, and firebase-tools are you using?

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024

Thanks for your speedy reply!

I have firebase-tools installed:
firebase-tools: 7.8.0
cypress: 3.4.1
cypress-firebase: 0.4.1

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024

I haven't tried get. I have tried set and delete commands. I will try get and let you know.

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024

Hmm, I'm not sure what I did, but now this is the error I am getting. This is for get, set, and delete commands:

CypressError: cy.exec('$(npm bin)/firebase-extra firestore get companies/DevAutomation/projects/DevAutomationProject/Test Cases/1') failed because the command exited with a non-zero code.

Pass {failOnNonZeroExit: false} to ignore exit code failures.

Information about the failure:
Code: 1

Stderr:
' is not recognized as an internal or external command,
operable program or batch file.

Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite: 'Client New Test Page'

This was the command I ran:

  before(() => {
    cy.tokenLoginAs("admin")
    cy.log("Retrieving test case...")
      .callFirestore("get", getTestCaseDocPath("admin", "1"))
      .as("testCase")

  })

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024

Good idea! I tried to do the \ just now, but same error. I also tried changing the space to %20 (which is what we had to do for firebase rules (to be honest, I wish we could change this, but this is in production code, so I need that. However, it seems that it cannot find the command. I ran this same command in the command line, except changed $(npm bin) to ./node_modules/.bin, and it ran the command just fine. Its only when I run it in cypress that it fails.

from cypress-firebase.

prescottprue avatar prescottprue commented on June 3, 2024

That is very intesting, not sure why I haven't experienced this. What type of machine are you using to run Cypress? Windows, mac, or linux?

Looks like we may have to switch things back to npx instead of using $(npm bin), so I'll look into making that change

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024

I'm on Windows 10. Thanks for your help! I really like this module.

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024

I changed this in constants.js on my end:

exports.FIREBASE_TOOLS_BASE_COMMAND = 'node_modules\\.bin\\firebase';
// Path to firebase-tools-extra Command Line tool (wrapper for firebase-tools)
exports.FIREBASE_EXTRA_PATH = 'node_modules\\.bin\\firebase-extra';

And it worked. However, I'm getting this error, but I don't think its related

Error: the string "(node:18408) UnhandledPromiseRejectionWarning: Error: Fixture not found at path: test\\e2e\\fixtures\\'{_id:Automation-Test-Case-1574356128828 ... }

I thought that the set command could have an object passed in (I have a function to generate my object to set the value to). Am I using it right? I'm asking in this since I'm making sure this change fixes it.

from cypress-firebase.

prescottprue avatar prescottprue commented on June 3, 2024

@dhair-seva Glad to hear switching it up worked. For passing in a fixture, you will want to have an object, but it seems like you might have passed a string since it thinks it is a fixture path?

Did you try switching them to using npx like npx firebase-extra ? I think that might be the best path forward since it will handle local and global versions

from cypress-firebase.

dhair-seva avatar dhair-seva commented on June 3, 2024

@prescottprue I haven't tried npx. I will when I get a chance. I passed in an object. This is what I used:

const testCase = generateTestCase()

  before(() => {
    cy.tokenLoginAs("admin")
    cy.log("Creating test case...")
      .callFirestore("set", getTestCaseDocPath("admin", testCase._id), testCase)
      .log("Test Case created.")

  })

generateTestCase returns an object like:
{ _id: 'my-custom-id', ... }

from cypress-firebase.

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.