Skip to content

Commit

Permalink
[Tests] filter out npm warnings, redux
Browse files Browse the repository at this point in the history
Followup to 2627cfa
  • Loading branch information
ljharb committed Jan 2, 2022
1 parent d78214e commit 5a63833
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Expand Up @@ -5,5 +5,6 @@

"rules": {
"array-bracket-newline": 0,
"func-style": 0,
},
}
12 changes: 10 additions & 2 deletions test/index.js
Expand Up @@ -7,6 +7,10 @@ const test = require('tape');

const cwd = process.cwd();

function hideWarnings(lines) {
return lines.filter((x) => !(/^npm WARN|^\(node:\d+\) ExperimentalWarning/).test(x));
}

test('fix option', (t) => {
t.plan(6);
process.chdir(path.join(__dirname, '..'));
Expand All @@ -17,11 +21,15 @@ test('fix option', (t) => {
t.ok(error.message.startsWith('Command failed: '), 'expected error message');
t.equal(error.code, 1, 'error code is 1');
t.match(
String(error).split('\n').filter((x) => !(/^npm WARN npm npm does not support Node.js /).test(x))[1],
hideWarnings(String(error).split('\n'))[1],
/^npm ERR! code (EAUDITNOLOCK|ENOLOCK)$/,
'error message has EAUDITNOLOCK or ENOLOCK'
);
t.equal(stdout, '', 'no stdout output');
t.match(stderr.split('\n')[0], /^npm ERR! code (EAUDITNOLOCK|ENOLOCK)$/, 'stderr starts with expected error code');
t.match(
hideWarnings(stderr.split('\n'))[0],
/^npm ERR! code (EAUDITNOLOCK|ENOLOCK)$/,
'stderr starts with expected error code'
);
});
});

0 comments on commit 5a63833

Please sign in to comment.