Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
files.forEach(file => {
if (file.name === 'node_modules') return
const fullPath = path.join(dir, file.name)
if (file.isDirectory()) return traverseFiles(fullPath)
const snapshotFile = path.join(dir, '__snapshots__', file.name + '.snap')
if (fs.existsSync(snapshotFile)) {
const snapshot = jestSnapshot.utils.getSnapshotData(snapshotFile)
const code = fs.readFileSync(fullPath, 'utf-8')
const ast = babelParser.parse(code)
const paths = []
let testName = null
let snapshotNumber = 0
const pushPath = path => {
const last = paths[paths.length - 1]
if (last && !last.isAncestor(path)) {
snapshotNumber = 0
paths.splice(0)
}
paths.push(path)
testName = paths.map(pickStringArgument).join(' ')
}