Skip to content
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

test: add tests for runner coverage with different stdout column widths #54494

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
49 changes: 49 additions & 0 deletions test/fixtures/test-runner/coverage-snap/a.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Empty functions that don't do anything
function doNothing1() {
// Not implemented
}

function doNothing2() {
// No logic here
}

function unusedFunction1() {
// Intentionally left empty
}

function unusedFunction2() {
// Another empty function
}

// Unused variables
const unusedVariable1 = "This is never used";
const unusedVariable2 = 42;
let unusedVariable3;

// Empty class with no methods
class UnusedClass {
constructor() {
// Constructor does nothing
}
}

// Empty object literal
const emptyObject = {};

// Empty array
const emptyArray = [];

// Function with parameters but no body
function doNothingWithParams(param1, param2) {
// No implementation
}

// Function that returns nothing
function returnsNothing() {
// No return statement
}

// Another unused function
function unusedFunction3() {
// More empty code
}
8 changes: 8 additions & 0 deletions test/fixtures/test-runner/coverage-snap/b.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Empty functions that don't do anything
function doNothing1() {
// Not implemented
}

function doNothing2() {
// No logic here
}
225 changes: 225 additions & 0 deletions test/fixtures/test-runner/coverage-snap/many-uncovered-lines.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
// Empty functions that don't do anything
function doNothing1() {
// Not implemented
}

function doNothing2() {
// No logic here
}

function unusedFunction1() {
// Intentionally left empty
}

function unusedFunction2() {
// Another empty function
}

// Unused variables
const unusedVariable1 = "This is never used";
const unusedVariable2 = 42;
let unusedVariable3;

// Empty class with no methods
class UnusedClass {
constructor() {
// Constructor does nothing
}
}

// Empty object literal
const emptyObject = {};

// Empty array
const emptyArray = [];

// Function with parameters but no body
function doNothingWithParams(param1, param2) {
// No implementation
}

// Function that returns nothing
function returnsNothing() {
// No return statement
}

// Another unused function
function unusedFunction3() {
// More empty code
}

// Empty functions with different signatures
function doNothing4() {
// No logic here
}

function doNothing5() {
// Another placeholder
}

function doNothingWithRestParams(...args) {
// Function with rest parameters but no logic
}

function doNothingWithCallback(callback) {
// Callback not called
}

// Unused variables of different types
const unusedVariable7 = null;
const unusedVariable8 = undefined;
const unusedVariable9 = Symbol('unused');
let unusedVariable10;

// Another empty class
class YetAnotherUnusedClass {
// No properties or methods
}

// Unused object with nested array
const unusedObjectWithArray = {
innerArray: []
};

// Another empty array
const anotherEmptyArray = [];

// Function with default and rest parameters
function anotherComplexFunction(param1 = 10, ...rest) {
// No implementation
}

// More unused functions
function unusedFunction5() {
// Placeholder
}

function unusedFunction6() {
// Empty again
}

function unusedFunction7() {
// Still nothing here
}

// Empty static method in class
class UnusedClassWithStaticMethod {
static unusedStaticMethod() {
// No logic inside static method
}
}

// Empty getter and setter in a class
class ClassWithGetterSetter {
get unusedGetter() {
// Empty getter
}

set unusedSetter(value) {
// Empty setter
}
}

// Unused function returning undefined
function returnsUndefined() {
return undefined;
}

// Empty promise-returning function
function emptyPromiseFunction() {
return new Promise((resolve, reject) => {
// No promise logic
});
}

// Empty immediately-invoked function expression (IIFE)
(function emptyIIFE() {
// No implementation
})();

// Unused generator function with parameters
function* unusedGeneratorFunctionWithParams(param1, param2) {
// No yielding of values
}

// Unused async arrow function
const unusedAsyncArrowFunction = async () => {
// No async logic here
};

// Unused map function with no logic
const unusedMapFunction = new Map();

// Unused set function with no logic
const unusedSetFunction = new Set();

// Empty for loop
for (let i = 0; i < 10; i++) {
// Loop does nothing
}

// Empty while loop
while (false) {
// Never executes
}

// Empty try-catch-finally block
try {
// Nothing to try
} catch (error) {
// No error handling
} finally {
// Nothing to finalize
}

// Empty if-else block
if (false) {
// No logic here
} else {
// Nothing here either
}

// Empty switch statement
switch (false) {
case true:
// No case logic
break;
default:
// Default does nothing
break;
}

// Empty nested function
function outerFunction() {
function innerFunction() {
// Empty inner function
}
}

// More unused arrow functions
const unusedArrowFunction1 = () => {};
const unusedArrowFunction2 = param => {};

// Empty function with a try-catch block
function emptyTryCatchFunction() {
try {
// Nothing to try
} catch (error) {
// No error handling
}
}

// Unused async generator function
async function* unusedAsyncGenerator() {
// No async yielding
}

// Unused function returning an empty array
function returnsEmptyArray() {
return [];
}

// Unused function returning an empty object
function returnsEmptyObject() {
return {};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Flags: --experimental-test-coverage
import * as a from '../coverage-snap/b.mjs';
import * as b from '../coverage-snap/a.mjs';
import * as c from '../coverage-snap/many-uncovered-lines.mjs';
import { test } from 'node:test';

process.stdout.columns = 100;

test(`Coverage Print Fixed Width ${process.stdout.columns}`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 100
ok 1 - Coverage Print Fixed Width 100
---
duration_ms: *
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# --------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# --------------------------------------------------------------------------------------------------
# …runner/coverage-snap/a.mjs | 53.06 | 100.00 | 0.00 | 2-4 6-8 10-12 14-16 26-27 37-39 42-4…
# …runner/coverage-snap/b.mjs | 25.00 | 100.00 | 0.00 | 2-4 6-8
# …p/many-uncovered-lines.mjs | 59.11 | 42.86 | 3.23 | 2-4 6-8 10-12 14-16 26-27 37-39 42-4…
# …dth-100-uncovered-lines.js | 100.00 | 100.00 | 100.00 |
# --------------------------------------------------------------------------------------------------
# all files | 58.42 | 60.00 | 2.44 |
# --------------------------------------------------------------------------------------------------
# end of coverage report
8 changes: 8 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-100.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Flags: --experimental-test-coverage
import * as a from '../coverage-snap/b.mjs';
import * as b from '../coverage-snap/a.mjs';
import { test } from 'node:test';

process.stdout.columns = 100;

test(`Coverage Print Fixed Width ${process.stdout.columns}`);
26 changes: 26 additions & 0 deletions test/fixtures/test-runner/output/coverage-width-100.snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
TAP version 13
# Subtest: Coverage Print Fixed Width 100
ok 1 - Coverage Print Fixed Width 100
---
duration_ms: *
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms *
# start of coverage report
# --------------------------------------------------------------------------------------------------
# file | line % | branch % | funcs % | uncovered lines
# --------------------------------------------------------------------------------------------------
# test/fixtures/test-runner/coverage-snap/a.mjs | 53.06 | 100.00 | 0.00 | 2-4 6-8 10-12 1…
# test/fixtures/test-runner/coverage-snap/b.mjs | 25.00 | 100.00 | 0.00 | 2-4 6-8
# …xtures/test-runner/output/coverage-width-100.js | 100.00 | 100.00 | 100.00 |
# --------------------------------------------------------------------------------------------------
# all files | 55.38 | 100.00 | 0.00 |
# --------------------------------------------------------------------------------------------------
# end of coverage report
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Flags: --experimental-test-coverage
import * as a from '../coverage-snap/b.mjs';
import * as b from '../coverage-snap/a.mjs';
import * as c from '../coverage-snap/many-uncovered-lines.mjs';
import { test } from 'node:test';

process.stdout.columns = 150;

test(`Coverage Print Fixed Width ${process.stdout.columns}`);
Loading
Loading