How to use the jest-snapshot.utils.getSnapshotData function in jest-snapshot

To help you get started, we’ve selected a few jest-snapshot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jest-community / jest-editor-support / src / Snapshot.js View on Github external
},
    };

    traverse(fileNode, {
      enter: path => {
        const visitor = Visitors[path.node.type];
        if (visitor != null) {
          visitor(path, state, this._matchers);
        }
      },
    });

    // NOTE if no projectConfig is given the default resolver will be used
    const snapshotResolver = buildSnapshotResolver(this._projectConfig || {});
    const snapshotPath = snapshotResolver.resolveSnapshotPath(filePath);
    const snapshots = utils.getSnapshotData(snapshotPath, 'none').data;
    let lastParent = null;
    let count = 1;

    return state.found.map(snapshotNode => {
      const parents = snapshotNode.parents.filter(isValidParent);
      const innerAssertion = parents[parents.length - 1];

      if (lastParent !== innerAssertion) {
        lastParent = innerAssertion;
        count = 1;
      }

      const result = {
        content: undefined,
        count,
        exists: false,