@@ -78,7 +78,14 @@ test('should ignore stdio when quiet', async ({ runInlineTest }) => {
78
78
expect ( result . output ) . not . toContain ( '%%' ) ;
79
79
} ) ;
80
80
81
- test ( 'should support console colors' , async ( { runInlineTest } ) => {
81
+ test ( 'should support console colors but not tty' , {
82
+ annotation : [
83
+ { type : 'issue' , description : 'https://github.com/microsoft/playwright/issues/15366' } ,
84
+ { type : 'issue' , description : 'https://github.com/microsoft/playwright/issues/29839' } ,
85
+ ] ,
86
+ } , async ( { runInlineTest, nodeVersion } ) => {
87
+ test . skip ( nodeVersion . major < 18 , 'Node16 does not respect FORCE_COLOR in onsole' ) ;
88
+
82
89
const result = await runInlineTest ( {
83
90
'a.spec.js' : `
84
91
import { test, expect } from '@playwright/test';
@@ -90,31 +97,13 @@ test('should support console colors', async ({ runInlineTest }) => {
90
97
});
91
98
`
92
99
} ) ;
93
- expect ( result . output ) . toContain ( `process.stdout.isTTY = true ` ) ;
94
- expect ( result . output ) . toContain ( `process.stderr.isTTY = true ` ) ;
100
+ expect ( result . output ) . toContain ( `process.stdout.isTTY = undefined ` ) ;
101
+ expect ( result . output ) . toContain ( `process.stderr.isTTY = undefined ` ) ;
95
102
// The output should have colors.
96
103
expect ( result . rawOutput ) . toContain ( `{ b: \x1b[33mtrue\x1b[39m, n: \x1b[33m123\x1b[39m, s: \x1b[32m'abc'\x1b[39m }` ) ;
97
104
expect ( result . rawOutput ) . toContain ( `{ b: \x1b[33mfalse\x1b[39m, n: \x1b[33m123\x1b[39m, s: \x1b[32m'abc'\x1b[39m }` ) ;
98
105
} ) ;
99
106
100
- test ( 'should override hasColors and getColorDepth' , async ( { runInlineTest } ) => {
101
- const result = await runInlineTest ( {
102
- 'a.spec.js' : `
103
- import { test, expect } from '@playwright/test';
104
- test('console log', () => {
105
- console.log('process.stdout.hasColors(1) = ' + process.stdout.hasColors(1));
106
- console.log('process.stderr.hasColors(1) = ' + process.stderr.hasColors(1));
107
- console.log('process.stdout.getColorDepth() > 0 = ' + (process.stdout.getColorDepth() > 0));
108
- console.log('process.stderr.getColorDepth() > 0 = ' + (process.stderr.getColorDepth() > 0));
109
- });
110
- `
111
- } ) ;
112
- expect ( result . output ) . toContain ( `process.stdout.hasColors(1) = true` ) ;
113
- expect ( result . output ) . toContain ( `process.stderr.hasColors(1) = true` ) ;
114
- expect ( result . output ) . toContain ( `process.stdout.getColorDepth() > 0 = true` ) ;
115
- expect ( result . output ) . toContain ( `process.stderr.getColorDepth() > 0 = true` ) ;
116
- } ) ;
117
-
118
107
test ( 'should not throw type error when using assert' , async ( { runInlineTest } ) => {
119
108
const result = await runInlineTest ( {
120
109
'a.spec.js' : `
@@ -128,30 +117,3 @@ test('should not throw type error when using assert', async ({ runInlineTest })
128
117
expect ( result . output ) . not . toContain ( `TypeError: process.stderr.hasColors is not a function` ) ;
129
118
expect ( result . output ) . toContain ( `AssertionError` ) ;
130
119
} ) ;
131
-
132
- test ( 'should provide stubs for tty.WriteStream methods on process.stdout/stderr' , async ( { runInlineTest } ) => {
133
- test . info ( ) . annotations . push ( { type : 'issue' , description : 'https://github.com/microsoft/playwright/issues/29839' } ) ;
134
- const result = await runInlineTest ( {
135
- 'a.spec.ts' : `
136
- import { test, expect } from '@playwright/test';
137
- import type * as tty from 'tty';
138
- async function checkMethods(stream: tty.WriteStream) {
139
- expect(stream.isTTY).toBe(true);
140
- await new Promise<void>(r => stream.clearLine(-1, r));;
141
- await new Promise<void>(r => stream.clearScreenDown(r));;
142
- await new Promise<void>(r => stream.cursorTo(0, 0, r));;
143
- await new Promise<void>(r => stream.cursorTo(0, r));;
144
- await new Promise<void>(r => stream.moveCursor(1, 1, r));;
145
- expect(stream.getWindowSize()).toEqual([stream.columns, stream.rows]);
146
- // getColorDepth() and hasColors() are covered in other tests.
147
- }
148
- test('process.stdout implementd tty.WriteStream methods', () => {
149
- checkMethods(process.stdout);
150
- });
151
- test('process.stderr implementd tty.WriteStream methods', () => {
152
- checkMethods(process.stderr);
153
- });
154
- `
155
- } ) ;
156
- expect ( result . exitCode ) . toBe ( 0 ) ;
157
- } ) ;
0 commit comments