Skip to content

Commit

Permalink
Update action tests workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotorres97 committed Dec 20, 2023
1 parent 0462fb5 commit 5bf300c
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
28 changes: 20 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,27 @@ name: Node CI
on: [push]

jobs:
build:

unit:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]
name: Node v${{ matrix.node }}

steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 14
- run: yarn
- run: yarn test
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js version
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}

- name: Install dependencies
run: yarn

- name: Run lint
run: yarn lint

- name: Run tests
run: yarn test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"test": "test"
},
"scripts": {
"lint": "uphold-scripts lint",
"lint": "uphold-scripts lint .",
"release": "release-it",
"test": "uphold-scripts test"
},
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* Module dependencies.
*/

const { serializeError } = require('serialize-error');
const { cloneDeep, cloneDeepWith, get, set } = require('lodash');
const { serializeError } = require('serialize-error');
const stringify = require('json-stringify-safe');
const traverse = require('traverse');

Expand Down Expand Up @@ -129,12 +129,12 @@ module.exports.anonymizer = (
const blacklistedKeys = new Set();
const obj = parseAndSerialize(values, serializers);

traverse(obj).forEach(function() {
traverse(obj).forEach(function () {
const path = this.path.join('.');
const isBuffer = Buffer.isBuffer(get(values, path));

if (trim) {
this.after(function(node) {
this.after(function (node) {
if (!this.isLeaf && Object.values(node).every(value => value === undefined)) {
return this.isRoot ? this.update(undefined, true) : this.delete();
}
Expand Down
21 changes: 17 additions & 4 deletions test/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,10 @@ describe('Anonymizer', () => {
return 'biz';
});
const whitelist = ['*'];
const serializers = [{ path: 'foo', serializer: foobar }, { path: 'foz', serializer: fozbar }];
const serializers = [
{ path: 'foo', serializer: foobar },
{ path: 'foz', serializer: fozbar }
];
const anonymize = anonymizer({ whitelist }, { serializers });

const result = anonymize(data);
Expand Down Expand Up @@ -478,7 +481,10 @@ describe('Anonymizer', () => {
const serializer = jest.fn(() => {
throw new Error('foobar');
});
const serializers = [{ path: 'foo', serializer }, { path: 'foz', serializer }];
const serializers = [
{ path: 'foo', serializer },
{ path: 'foz', serializer }
];
const whitelist = ['*'];
const anonymize = anonymizer({ whitelist }, { serializers });

Expand All @@ -495,7 +501,11 @@ describe('Anonymizer', () => {
it('should serialize errors when `serializeError()` is applied', () => {
const error = new Error('foobar');
const serializer = jest.fn(serializeError);
const serializers = [{ path: 'e', serializer }, { path: 'err', serializer }, { path: 'error', serializer }];
const serializers = [
{ path: 'e', serializer },
{ path: 'err', serializer },
{ path: 'error', serializer }
];
const whitelist = ['*'];
const anonymize = anonymizer({ whitelist }, { serializers });

Expand Down Expand Up @@ -530,7 +540,10 @@ describe('Anonymizer', () => {
it('should serialize errors when `datadogSerializer()` is applied', () => {
const error = new Error('foobar');
const serializer = jest.fn(datadogSerializer);
const serializers = [{ path: 'err', serializer }, { path: 'error', serializer }];
const serializers = [
{ path: 'err', serializer },
{ path: 'error', serializer }
];
const whitelist = ['error.foo', 'error.kind', 'error.message', 'error.name', 'error.stack'];
const anonymize = anonymizer({ whitelist }, { serializers });

Expand Down

0 comments on commit 5bf300c

Please sign in to comment.