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.15.1 to 1.16.0

2

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

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

@@ -46,2 +46,24 @@ # find-test-names [![ci](https://github.com/bahmutov/find-test-names/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/find-test-names/actions/workflows/ci.yml)

### setEffectiveTags
Often, you want to have each test and see which tags it has and what parent tags apply to it. You can compute for each test a list of _effective_ tags and set it for each test.
```js
// example spec code
describe('parent', { tags: '@user' }, () => {
describe('parent', { tags: '@auth' }, () => {
it('works a', { tags: '@one' }, () => {})
it('works b', () => {})
})
})
```
```js
const { getTestNames, setEffectiveTags } = require('find-test-names')
const result = getTestNames(source, true)
setEffectiveTags(result.structure)
```
If you traverse the `result.structure`, the test "works a" will have the `effectiveTags` list with `@user, @auth, @one`, and the test "works b" will have the `effectiveTags` list with `@user, @auth, @one`.
### Bin

@@ -48,0 +70,0 @@

@@ -435,2 +435,24 @@ const babel = require('@babel/parser')

/**
* Visits each test and counts its tags and its parents' tags
* to compute the "effective" tags list.
*/
function setEffectiveTags(structure) {
setParentSuite(structure)
visitEachTest(structure, (test, parentSuite) => {
// normalize the tags to be an array of strings
const ownTags = [].concat(test.tags || [])
// also consider the effective tags by traveling up
// the parent chain of suites
const suiteTags = collectSuiteTagsUp(parentSuite)
const allTags = [...ownTags, ...suiteTags]
const uniqueTags = [...new Set(allTags)]
test.effectiveTags = uniqueTags.sort()
})
return structure
}
function setParentSuite(structure) {

@@ -588,2 +610,3 @@ visitEachNode(structure, (test, parentSuite) => {

setParentSuite,
setEffectiveTags,
}
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