Skip to content

ref(node): Improve Node manual test logging #5088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/node/test/manual/colorize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const COLOR_RESET = '\x1b[0m';
const COLORS = {
green: '\x1b[32m',
red: '\x1b[31m',
yellow: '\x1b[33m',
};

function colorize(str, color) {
if (!(color in COLORS)) {
throw new Error(`Unknown color. Available colors: ${Object.keys(COLORS).join(', ')}`);
}

return `${COLORS[color]}${str}${COLOR_RESET}`;
}

module.exports = { colorize };
5 changes: 3 additions & 2 deletions packages/node/test/manual/express-scope-separation/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ const http = require('http');
const express = require('express');
const app = express();
const Sentry = require('../../../build/cjs');
const { colorize } = require('../colorize');

// don't log the test errors we're going to throw, so at a quick glance it doesn't look like the test itself has failed
global.console.error = () => null;

function assertTags(actual, expected) {
if (JSON.stringify(actual) !== JSON.stringify(expected)) {
console.error('FAILED: Scope contains incorrect tags');
console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red'));
process.exit(1);
}
}
Expand All @@ -20,7 +21,7 @@ function makeDummyTransport() {
--remaining;

if (!remaining) {
console.error('SUCCESS: All scopes contain correct tags');
console.log(colorize('PASSED: All scopes contain correct tags\n', 'green'));
server.close();
process.exit(0);
}
Expand Down
16 changes: 1 addition & 15 deletions packages/node/test/manual/release-health/runner.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
const fs = require('fs');
const path = require('path');
const { spawn } = require('child_process');

const COLOR_RESET = '\x1b[0m';
const COLORS = {
green: '\x1b[32m',
red: '\x1b[31m',
yellow: '\x1b[33m',
};

const colorize = (str, color) => {
if (!(color in COLORS)) {
throw new Error(`Unknown color. Available colors: ${Object.keys(COLORS).join(', ')}`);
}

return `${COLORS[color]}${str}${COLOR_RESET}`;
};
const { colorize } = require('../colorize');

const scenariosDirs = ['session-aggregates', 'single-session'];
const scenarios = [];
Expand Down
7 changes: 4 additions & 3 deletions packages/node/test/manual/webpack-domain/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Sentry = require('../../../build/cjs');
const { colorize } = require('../colorize');

let remaining = 2;

Expand All @@ -7,7 +8,7 @@ function makeDummyTransport() {
--remaining;

if (!remaining) {
console.error('SUCCESS: Webpack Node Domain test OK!');
console.log(colorize('PASSED: Webpack Node Domain test OK!\n', 'green'));
process.exit(0);
}

Expand All @@ -23,13 +24,13 @@ Sentry.init({
beforeSend(event) {
if (event.message === 'inside') {
if (event.tags.a !== 'x' && event.tags.b !== 'c') {
console.error('FAILED: Scope contains incorrect tags');
console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red'));
process.exit(1);
}
}
if (event.message === 'outside') {
if (event.tags.a !== 'b') {
console.error('FAILED: Scope contains incorrect tags');
console.log(colorize('FAILED: Scope contains incorrect tags\n', 'red'));
process.exit(1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/node/test/manual/webpack-domain/npm-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ webpack(

function runTests() {
try {
execSync('node ' + path.resolve(__dirname, 'dist', 'bundle.js'));
execSync('node ' + path.resolve(__dirname, 'dist', 'bundle.js'), { stdio: 'inherit' });
} catch (_) {
process.exit(1);
}
Expand Down