| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  | /** | 
					
						
							|  |  |  |  * Copyright (c) Microsoft Corporation. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
					
						
							|  |  |  |  * you may not use this file except in compliance with the License. | 
					
						
							|  |  |  |  * You may obtain a copy of the License at | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * http://www.apache.org/licenses/LICENSE-2.0
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Unless required by applicable law or agreed to in writing, software | 
					
						
							|  |  |  |  * distributed under the License is distributed on an "AS IS" BASIS, | 
					
						
							|  |  |  |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
					
						
							|  |  |  |  * See the License for the specific language governing permissions and | 
					
						
							|  |  |  |  * limitations under the License. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { test, expect } from './playwright-test-fixtures'; | 
					
						
							|  |  |  | import * as path from 'path'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const tests = { | 
					
						
							|  |  |  |   'a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |     const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |     test('pass', ({}) => {}); | 
					
						
							|  |  |  |   `,
 | 
					
						
							|  |  |  |   'b.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |     const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |     test('pass', ({}) => {}); | 
					
						
							|  |  |  |   `,
 | 
					
						
							|  |  |  |   'c.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |     const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |     test('pass', ({}) => {}); | 
					
						
							|  |  |  |   `
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should run all three tests', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest(tests); | 
					
						
							|  |  |  |   expect(result.passed).toBe(3); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should ignore a test', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     ...tests, | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       module.exports = { testIgnore: 'b.test.ts' }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should ignore a folder', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       module.exports = { testIgnore: 'folder/**' }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'folder/a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'folder/b.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'folder/c.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(1); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should ignore a node_modules', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'node_modules/a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'node_modules/b.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'folder/c.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should filter tests', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     ...tests, | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       module.exports = { testIgnore: 'c.test.*' }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should use a different test match', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     ...tests, | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       module.exports = { testMatch: '[a|b].test.ts' }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should use an array for testMatch', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       module.exports = { testMatch: ['b.test.ts', /\\${path.sep}a.[tes]{4}.TS$/i] }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'b.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'c.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['b.test.ts', 'dir/a.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should match absolute path', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       import * as path from 'path'; | 
					
						
							|  |  |  |       module.exports = { testDir: path.join(__dirname, 'dir'), testMatch: /dir\\${path.sep}a/ }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/b.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(1); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['a.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should match cli string argument', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       import * as path from 'path'; | 
					
						
							|  |  |  |       module.exports = { testDir: path.join(__dirname, 'dir') }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/b.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							| 
									
										
										
										
											2022-02-10 07:02:37 -08:00
										 |  |  |   }, {}, {}, { additionalArgs: [`dir\\${path.sep}a`] }); | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |   expect(result.passed).toBe(1); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['a.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should match regex string argument', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'dir/filea.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/fileb.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'filea.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							| 
									
										
										
										
											2021-09-20 17:17:12 -07:00
										 |  |  |   }, {}, {}, { additionalArgs: ['/filea.*ts/'] }); | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['dir/filea.test.ts', 'filea.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-24 10:02:34 +02:00
										 |  |  | test('should match regex string with a colon argument', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   test.skip(process.platform === 'win32', 'Windows does not support colons in the file name'); | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'fileb.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'weird:file.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							| 
									
										
										
										
											2021-09-20 17:17:12 -07:00
										 |  |  |   }, {}, {}, { additionalArgs: ['/weird:file\.test\.ts/'] }); | 
					
						
							| 
									
										
										
										
											2021-06-24 10:02:34 +02:00
										 |  |  |   expect(result.passed).toBe(1); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['weird:file.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-15 17:27:52 -07:00
										 |  |  | test('should match case insensitive', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'capital/A.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'lowercase/a.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'b.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							| 
									
										
										
										
											2021-09-20 17:17:12 -07:00
										 |  |  |   }, {}, {}, { additionalArgs: ['a.test.ts'] }); | 
					
						
							| 
									
										
										
										
											2021-06-15 17:27:52 -07:00
										 |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['capital/A.test.ts', 'lowercase/a.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  | test('should match by directory', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'dir-a/file.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir-b/file1.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir-b/file2.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'file.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							| 
									
										
										
										
											2021-09-20 17:17:12 -07:00
										 |  |  |   }, {}, {}, { additionalArgs: ['dir-b'] }); | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['dir-b/file1.test.ts', 'dir-b/file2.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should ignore node_modules even with custom testIgnore', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       module.exports = { testIgnore: 'a.test.ts' }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'node_modules/a.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'node_modules/b.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'folder/c.test.ts': `
 | 
					
						
							| 
									
										
										
										
											2021-06-06 22:07:07 -07:00
										 |  |  |       const { test } = pwt; | 
					
						
							| 
									
										
										
										
											2021-06-06 17:09:53 -07:00
										 |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(1); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							| 
									
										
										
										
											2021-06-10 07:41:57 -07:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should only match files with JS/TS file extensions', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       module.exports = { testMatch: /foobar/ }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'foobar.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'foobar.test.js': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'foobar.test.ts-snapshots/compares-page-screenshot-chromium-linux-test-chromium.png': `
 | 
					
						
							|  |  |  |       <S0MeTh1ngN0nPArsAble! | 
					
						
							|  |  |  |     `
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-09-07 10:32:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | test('should match dot-files', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     '.a.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(1); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['.a.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | test('should match in dot-directories', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     '.dir/a.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     '.dir/b.test.js': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   expect(result.passed).toBe(2); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['.dir/a.test.ts', '.dir/b.test.js']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-09-13 12:09:38 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | test('should always work with unix separators', async ({ runInlineTest }) => { | 
					
						
							|  |  |  |   // Cygwin or Git Bash might send us a path with unix separators.
 | 
					
						
							|  |  |  |   const result = await runInlineTest({ | 
					
						
							|  |  |  |     'playwright.config.ts': `
 | 
					
						
							|  |  |  |       import * as path from 'path'; | 
					
						
							|  |  |  |       module.exports = { testDir: path.join(__dirname, 'dir') }; | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/a.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'dir/b.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |     'a.test.ts': `
 | 
					
						
							|  |  |  |       const { test } = pwt; | 
					
						
							|  |  |  |       test('pass', ({}) => {}); | 
					
						
							|  |  |  |     `
 | 
					
						
							| 
									
										
										
										
											2021-09-20 17:17:12 -07:00
										 |  |  |   }, {}, {}, { additionalArgs: [`dir/a`] }); | 
					
						
							| 
									
										
										
										
											2021-09-13 12:09:38 -04:00
										 |  |  |   expect(result.passed).toBe(1); | 
					
						
							|  |  |  |   expect(result.report.suites.map(s => s.file).sort()).toEqual(['a.test.ts']); | 
					
						
							|  |  |  |   expect(result.exitCode).toBe(0); | 
					
						
							|  |  |  | }); |