question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error when running all snapshots

See original GitHub issue

Hi, thanks for the amazing plugin!!!

There is a possible bug, as when I run all tests in the cypress browser I receive following error:

CypressError: cy.task('cypress-plugin-snapshot:matchText') failed with the following error:

> Error: Cannot load snapshot file. File "__snapshots__/__all.snap does not contain valid JSON or javascript

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:24 (7 by maintainers)

github_iconTop GitHub Comments

27reactions
bahmutovcommented, Jul 24, 2019

So the workaround I can offer for now is to fix Cypress.spec object by looking at the __filename in each spec file. Here is the code to place into cypress/support/index.js. It is a utility function that forms Cypress.spec from passed filename

// cypress/support/index.js
export const fixCypressSpec = filename => () => {
  const path = require('path')
  const relative = filename.substr(1) // removes leading "/"
  const projectRoot = Cypress.config('projectRoot')
  const absolute = path.join(projectRoot, relative)
  Cypress.spec = {
    absolute,
    name: path.basename(filename),
    relative
  }
}

From each spec file (that wants to use snapshots)

import { fixCypressSpec } from '../support'

beforeEach(fixCypressSpec(__filename))

I have been playing with this in https://github.com/bahmutov/objection-example using this approach to run all specs with snapshots

7reactions
sgnlcommented, May 1, 2019

IMO this issue should be mentioned on the README as it’s a huge blocker for me, I only found out after implementing and writing tests (using .only while writing tests) to find the error in the GUI test runner after I ran all my tests which made all my work previously useless.

Please consider adding an eye-catching warning or ‘caveat’ section which mentions this issue so that other users of this package will not share the same experience I had or at the very least, know of this important bug.

Hope Cypress gets the fix in soon, :fingers

(added a PR as a suggestion for a new section in the README file: https://github.com/meinaart/cypress-plugin-snapshots/pull/37)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot stuck EBS snapshots - AWS
The ConcurrentSnapshotLimitExceeded error might occur for the following reasons: You have too many snapshots running concurrently.
Read more >
Solved: Snapshots fail with "A general system error occurr...
When the snapshots finished that appear all the veeam backups snapshot as described in this article. Delete all snapshots and Veeam backup runs...
Read more >
Troubleshoot Reporting Snapshots - Salesforce Help
If field mappings failed, the snapshot still runs, but the run history shows that there was a partial error. A reporting snapshot could...
Read more >
Error during snapshot retention task - how to solve ... - Opster
How to troubleshoot Elasticsearch/OpenSearch log "Error during snapshot retention task" a ... Get all currently running tasks on all nodes of the cluster....
Read more >
Error In Dropping Snapshots Process - During Data Collections
Information in this document applies to any platform. Symptoms. EBS Source version 12.2.4. VCP 12.2.4.1. Errors when running Data Collections ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found