Skip to content

Commit

Permalink
added warning for old collection comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Feb 16, 2024
1 parent 49f3c89 commit 4ebcd74
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 2.3.2
- added warning for old collection comments

* 2.3.1
- updated coverage reports

Expand Down
6 changes: 4 additions & 2 deletions lib/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ const defaultOptions = require('../default/options.js');
const assetsName = 'assets';

const Util = {
... Share,

root: process.cwd(),
EC,
CG,

... Share,
root: process.cwd(),

relativePath: function(p, root) {
p = `${p}`;
Expand Down
17 changes: 15 additions & 2 deletions lib/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ const {
const Util = require('./utils/util.js');
const commentsPlugin = require('./plugins/comments.js');
const defaultColumns = require('./default/columns.js');

// retired, just warning for old babel parser
let collectWarning = '"collect.comments()" has been deprecated (replaced with new option "customFieldsInComments: true/false" in version 2.2.0), please remove the code related to "collect.comments()" in custom "visitor".';
const collect = new Proxy({}, {
get: function(obj, prop) {
if (collectWarning) {
Util.logError(collectWarning);
collectWarning = null;
}
return () => {};
}
});

class Visitor {
constructor(root, options) {
this.root = root;
Expand Down Expand Up @@ -111,13 +124,13 @@ class Visitor {

// for all data
if (this.customCommonVisitor) {
await this.customCommonVisitor.call(this, data, metadata);
await this.customCommonVisitor.call(this, data, metadata, collect);
}

// for single column data (high priority)
if (this.customVisitors) {
for (const item of this.customVisitors) {
const res = await item.visitor.call(this, data, metadata);
const res = await item.visitor.call(this, data, metadata, collect);
if (typeof res !== 'undefined') {
data[item.id] = res;
}
Expand Down
8 changes: 7 additions & 1 deletion tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ module.exports = {
},

// additional custom visitor for columns
visitor: (data, metadata) => {
visitor: (data, metadata, collect) => {

// remove secrets and sensitive data
if (data.type === 'step') {
Expand All @@ -314,6 +314,12 @@ module.exports = {

}

// test issue #91
const comments = collect.comments();
if (comments) {
Object.assign(data, comments);
}


},

Expand Down

0 comments on commit 4ebcd74

Please sign in to comment.