Comments (28)
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.
@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.
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.
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:
- Install from alpha and install firebase-admin
npm i --save-dev cypress-firebase@alpha firebase-admin
(currently at 0.11.0-alpha.2) - Switch your plugin import to be
pluginWithTasks
like so:
- const cypressFirebasePlugin = require('cypress-firebase').plugin
+ const cypressFirebasePlugin = require('cypress-firebase').pluginWithTasks
- 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.
Thanks for reporting. Yeah it should support both
from cypress-firebase.
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.
@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' })
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.
Interesting. I didn't realize there was a new version. I will try that now.
from cypress-firebase.
I just updated and tried it in 0.5.0 and still receiving the same error.
from cypress-firebase.
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.
What version of firebase-tools-extra is installed? Also, what about firebase-tools?
from cypress-firebase.
firebase-tools: 7.8.0
firebase-tools-extra: 0.2.1
from cypress-firebase.
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.
Can we reopen this?
from cypress-firebase.
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.
from cypress-firebase.
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.
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.
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.
from cypress-firebase.
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.
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.
from cypress-firebase.
Great! Yes correct, it will most likely be in firebase-tools-extra
from cypress-firebase.
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.
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.
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.
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)
- publish-npm failing Error: Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 1
- bug: cannot read properties of undefined (reading 'includes') HOT 4
- Login after a logout happening the application fails
- Cypress e2e test fails initialization HOT 1
- feat(build): native esm support
- fix: drop support for node pre 16 HOT 2
- Support passing user claims to cy.login() ? HOT 1
- Invalid options types are ignored, rather than erroring
- The automated release is failing 🚨
- bug(docs): README.md setup is not clear about service account HOT 6
- Retry on 401
- bug(firestore): FieldValue.delete() not handled correctly HOT 3
- feat(callFirestore): ability to use batch writes
- bug(firestore): nested Timestamp value not persisting HOT 3
- bug: callFirestore not recognized in NextJS test HOT 1
- feat: support for component testing
- feat: switch to modular firebase sdks internally HOT 2
- bug(core): Webpack error when running cypress tests with cypress-firebase HOT 10
- callFirestore task fails when running in the CI with message "PERMISSION_DENIED: Missing or insufficient permissions." HOT 1
- Problem with Token HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cypress-firebase.