Git Product home page Git Product logo

Comments (28)

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

Actually, looks like the error is displayed here.
https://github.com/prescottprue/firebase-tools-extra/blob/master/src/commands/firestore.ts
I'm trying to look into this bug, because my workaround is really making a lot of code. (writing a file everytime I need to update an object in firestore.

from cypress-firebase.

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

@prescottprue Okay, so I tried this same command on my MAC, and it works just fine. This is a Windows-specific bug.

from cypress-firebase.

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

I have a temporary workaround. Basically we save the object and then use that as a fixture. It works for our use case and we have used over 50 e2e tests with it. Obviously its not ideal, but it works for now.

import { isObject } from "lodash"
import * as uuid from "uuid/v4"

Cypress.Commands.overwrite("callFirestore", (originalFn: any, type: string, path: any, fixtureOrData: string | any, ...args) => {
  let id = ""
  if (isObject(fixtureOrData)) {
    id = (fixtureOrData as any)._id
    if (!id) {
      id = "Automation-" + uuid()
    }

    const fixturePath = "test-fixtures/" + id + ".json"
    return cy
      .writeFile("cypress/fixtures/" + fixturePath, fixtureOrData, "utf-8")
      .then(() => {
        fixtureOrData = fixturePath
        return originalFn(type, path, fixtureOrData, ...args)
      })
  }

  return originalFn(type, path, fixtureOrData, ...args)
})

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024 1

I have started work on a new method of doing things (through tasks instead of passing through the firebase-tools-extra cli). This should help fix things, but it is definetly a work in progress

To try it out do the following:

  1. Install from alpha and install firebase-admin npm i --save-dev cypress-firebase@alpha firebase-admin (currently at 0.11.0-alpha.2)
  2. Switch your plugin import to be pluginWithTasks like so:
- const cypressFirebasePlugin = require('cypress-firebase').plugin
+ const cypressFirebasePlugin = require('cypress-firebase').pluginWithTasks
  1. Pass the new arguments to the new plugin:
+ const admin = require('firebase-admin')
const cypressFirebasePlugin = require('cypress-firebase').pluginWithTasks

module.exports = (on, config) => {
+  return cypressFirebasePlugin(on, config, admin)
-  return cypressFirebasePlugin(config)
}

Full example

const admin = require('firebase-admin')
const cypressFirebasePlugin = require('cypress-firebase').pluginWithTasks

module.exports = (on, config) => {
// Pass on function, config, and admin instance. Returns extended config
  return cypressFirebasePlugin(on, config, admin)
}

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

Thanks for reporting. Yeah it should support both

from cypress-firebase.

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

Interesting, When I run this command manually, I get that same error:
.\node_modules\.bin\npx firebase-extra firestore update 'companies/mycomp' '{"creditsRemaining":1000}' -P my-project

So it seems that firebase-extra is the one with the issue?

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

@dhair-seva Did you try updating to v0.5.0? I tried to replicate and am not seeing that issue anymore with that version (see below), I didn't realize earlier when you posted that you were using 0.4.1.

When calling the following:
cy.callFirestore('update', 'projects/123ABC', { some: 'otherdata' })

Result in logs is successful:
image

The same also works with set.

Going to close for now, but let me know if v0.5.0 doesn't work for you as expected and we can reopen

from cypress-firebase.

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

Interesting. I didn't realize there was a new version. I will try that now.

from cypress-firebase.

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

I just updated and tried it in 0.5.0 and still receiving the same error.

from cypress-firebase.

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

Could it be the firebase-extra command that we use is out of date on mine? I imagine not, but that seems like it would be the only reason...

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

What version of firebase-tools-extra is installed? Also, what about firebase-tools?

from cypress-firebase.

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

firebase-tools: 7.8.0
firebase-tools-extra: 0.2.1

from cypress-firebase.

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

Any ideas? This is really blocking a lot of my e2e testing. I would love to help contribute, but not sure where else to look for, on where the bug would be.

from cypress-firebase.

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

Can we reopen this?

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

Not sure of how to replicate - On both Mac and Linux I am able to pass the object and it is handled correctly. Do you have anything setup, like a CI provider, that is experiencing this on linux?

I'll try replicating again, but as pictured above it seemed to be working last time I tried

Something to note though is that it doesn't seem that the -D flag was added on the command that was generated for you, where it was on mine when passed the same arguments, so I'm going to look into the logic for that

from cypress-firebase.

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

from cypress-firebase.

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

Something to note though is that it doesn't seem that the -D flag was added on the command that was generated for you, where it was on mine when passed the same arguments, so I'm going to look into the logic for that

In looking at your screenshot of your command, I don't see a -D command. What does -D do?

from cypress-firebase.

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

I'm getting this same command in my current PR feature/dmh/fix-firebase-path. The one that I have for another issue I logged. I ran this command:
node_modules\.bin\firebase-extra firestore set "companies/DevAutomation/1575951379044" '{"_id":"1"}' -P testramp-dan
I received the same error, so its not specific to my cypress app. I'm more convinced that its windows. I have a MAC computer that I generally dont use for programming, but I'm going to try the command

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

Yeah that sound right that it would be due to the OS - I haven't gotten the chance to test any of these tools on Windows.

What I was mentioning with -d is actually in reference to calling firebase-tools directly, which doesn't apply here (since firebase-extra is being called).

from cypress-firebase.

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

from cypress-firebase.

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

Any update on this? You have a tag for "Needs Repro", but this happens in any windows machine. Can we remove it?

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

I don't currently have a windows machine to test on, and it will be a little while until I can get a chance to spin up a vm for testing this. I'll remove the needs-repro label, but I will need to reproduce on a windows machine so I can make changes to fix the issue. Unless you would be open to making a PR?

from cypress-firebase.

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

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

Great! Yes correct, it will most likely be in firebase-tools-extra

from cypress-firebase.

Alberick avatar Alberick commented on June 13, 2024

Hello, I just started looking at this package. I'm also using windows and I'm facing the same scenario. This is what I get when it runs on cypress.

Console was cleared
cypress_runner.js:159056 Command:     exec
cypress_runner.js:159056 Yielded:     Objectcode: 1stderr: ""stdout: ""__proto__: Object
cypress_runner.js:159056 Error:       CypressError: cy.exec('npx firebase-extra firestore set config/tester '{"name":"tester"}' -P myProject') failed because the command exited with a non-zero code.

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

Information about the failure:
Code: 1


Because this error occurred during a 'before all' hook we are skipping the remaining tests in the current suite: 'Select/Deselect all queries'
cypress_runner.js:159056 Snapshot:    The snapshot is missing. Displaying current state of the DOM.

This works fine If I run on the cli npx firebase-extra firestore set config/tester '{"name":"tester"}'

Do you have any advice or workaround I can use?

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

I have already noticed a few small things that should be fixed and improved - all changes are going out to the alpha tag for now, so feel free to just point to that in your package file if you want to keep getting updates of these versions while they progress

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

The v1.0.0 pre-release series now uses tasks by default and is being released on the next tag. Going to leave this open until it is released as latest.

Please reach out if you have any issues using the new plugin with tasks (available in 0.11.0) or using the new 1.0.0 pre-releases

from cypress-firebase.

prescottprue avatar prescottprue commented on June 13, 2024

v1.0.0 has been released to latest - everything is now going through tasks, so parsing should hopefully not be an issue regardless of os. Let me know if you get a chance to try it out!

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.