New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

find-test-names

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

find-test-names - npm Package Compare versions

Comparing version 1.13.0 to 1.14.0

2

package.json
{
"name": "find-test-names",
"version": "1.13.0",
"version": "1.14.0",
"description": "Given a Mocha / Cypress spec file, returns the list of suite and test names",

@@ -5,0 +5,0 @@ "main": "src",

@@ -343,2 +343,11 @@ const babel = require('@babel/parser')

function collectSuiteTagsUp(suite) {
const tags = []
while (suite) {
tags.push(...(suite.tags || []))
suite = suite.parent
}
return tags
}
/**

@@ -349,9 +358,9 @@ * Synchronous tree walker, calls the given callback for each test.

*/
function visitEachTest(structure, fn) {
function visitEachTest(structure, fn, parentSuite) {
structure.forEach((t) => {
if (t.type === 'suite') {
visitEachTest(t.tests, fn)
visitEachTest(t.tests, fn, t)
visitEachTest(t.suites, fn)
} else {
fn(t)
fn(t, parentSuite)
}

@@ -361,2 +370,12 @@ })

function visitEachNode(structure, fn, parentSuite) {
structure.forEach((t) => {
fn(t, parentSuite)
if (t.type === 'suite') {
visitEachNode(t.tests, fn, t)
visitEachNode(t.suites, fn, t)
}
})
}
/**

@@ -368,9 +387,8 @@ * Counts the tags found on the tests.

function countTags(structure) {
setParentSuite(structure)
const tags = {}
visitEachTest(structure, (test) => {
if (!test.tags) {
return
}
visitEachTest(structure, (test, parentSuite) => {
// normalize the tags to be an array of strings
const list = [].concat(test.tags)
const list = [].concat(test.tags || [])
list.forEach((tag) => {

@@ -383,2 +401,13 @@ if (!(tag in tags)) {

})
// also consider the effective tags by traveling up
// the parent chain of suites
const suiteTags = collectSuiteTagsUp(parentSuite)
suiteTags.forEach((tag) => {
if (!(tag in tags)) {
tags[tag] = 1
} else {
tags[tag] += 1
}
})
})

@@ -389,2 +418,10 @@

function setParentSuite(structure) {
visitEachNode(structure, (test, parentSuite) => {
if (parentSuite) {
test.parent = parentSuite
}
})
}
/**

@@ -530,2 +567,4 @@ * Returns all suite and test names found in the given JavaScript

countTags,
visitEachNode,
setParentSuite,
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc