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.21.0 to 1.22.0

14

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

@@ -47,9 +47,9 @@ "main": "src",

"devDependencies": {
"ava": "^3.15.0",
"common-tags": "^1.8.2",
"husky": "^7.0.4",
"prettier": "^2.4.1",
"semantic-release": "^18.0.0",
"stop-only": "^3.1.2"
"ava": "5.1.0",
"common-tags": "1.8.2",
"husky": "7.0.4",
"prettier": "2.7.1",
"semantic-release": "18.0.1",
"stop-only": "3.1.2"
}
}

@@ -93,4 +93,8 @@ # 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)

Returns a single object with full test titles as keys. For each key, the value is the list of effective tags. See the [find-effective-tags.js](./test/find-effective-tags.js) spec file. You can use the utility method `findEffectiveTestTags(filename)` to let this module read the file from disk.
Returns a single object with full test titles as keys. For each key, the value is the list of effective tags. See the [find-effective-tags.js](./test/find-effective-tags.js) spec file.
### findEffectiveTestTagsIn
You can use the utility method `findEffectiveTestTagsIn(filename)` to let this module read the file from disk and find the effective tags that apply to each test by its full title.
### Bin

@@ -157,2 +161,16 @@

### comment lines
If the test function has preceding comment lines, the comment line right before the test is extracted and included
```js
// line 1
// line 2
// line 3
it('works', ...)
// extracted test object will have
// name: "works",
// comment: "line 3"
```
## Debugging

@@ -172,2 +190,4 @@

- [cypress.tips](https://cypress.tips)
- [Cypress Tips & Tricks Newsletter](https://cypresstips.substack.com/)
- [my Cypress courses](https://cypress.tips/courses)

@@ -174,0 +194,0 @@ License: MIT - do anything with the code, but don't blame me if it does not work.

@@ -190,3 +190,3 @@ const babel = require('@babel/parser')

* i.e. walk.ancestor is called with the deepest node first, usually an "it",
* and a list of its ancestors. (other AST walkers travserse from the top)
* and a list of its ancestors. (other AST walkers traverse from the top)
*

@@ -532,2 +532,18 @@ * Since the tree generation starts from it nodes, this function cannot find

function getLeadingComment(ancestors) {
if (ancestors.length > 1) {
const a = ancestors.at(-2)
if (a.leadingComments && a.leadingComments.length) {
// grab the last comment line
const firstComment = a.leadingComments.at(-1)
if (firstComment.type === 'CommentLine') {
const leadingComment = firstComment.value
if (leadingComment.trim()) {
return leadingComment.trim()
}
}
}
}
}
/**

@@ -618,2 +634,7 @@ * Returns all suite and test names found in the given JavaScript

debug('found test "%s"', testInfo.name)
const comment = getLeadingComment(ancestors)
if (comment) {
testInfo.comment = comment
debug('found leading test comment "%s", comment')
}

@@ -644,2 +665,8 @@ const { suite, topLevelTest } = getSuiteAncestorsForTest(

const comment = getLeadingComment(ancestors)
if (comment) {
testInfo.comment = comment
debug('found leading skipped test comment "%s", comment')
}
const { suite, topLevelTest } = getSuiteAncestorsForTest(

@@ -646,0 +673,0 @@ test,

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