13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- import childProcess from 'child_process' ;
17
16
import fs from 'fs' ;
18
17
import path from 'path' ;
19
18
import { assertLockFilesExist , expect , packageManagerToNpxCommand , test } from './baseFixtures' ;
@@ -97,12 +96,12 @@ test('should generate be able to run JS examples successfully', async ({ run, di
97
96
await exec ( packageManagerToNpxCommand ( packageManager ) , [ 'playwright' , 'test' ] ) ;
98
97
} ) ;
99
98
100
- test ( 'should generate in the root of pnpm workspace' , async ( { run, packageManager } ) => {
99
+ test ( 'should generate in the root of pnpm workspace' , async ( { run, packageManager, exec } ) => {
101
100
test . skip ( packageManager !== 'pnpm' ) ;
102
101
103
102
const dir = test . info ( ) . outputDir ;
104
103
fs . mkdirSync ( dir , { recursive : true } ) ;
105
- childProcess . execSync ( 'pnpm init' , { cwd : dir } ) ;
104
+ await exec ( 'pnpm' , [ ' init'] , { cwd : dir } ) ;
106
105
fs . writeFileSync ( path . join ( dir , 'pnpm-workspace.yaml' ) , `packages:\n - 'packages/*'\n` ) ;
107
106
fs . mkdirSync ( path . join ( dir , 'packages' , 'foo' ) , { recursive : true } ) ;
108
107
fs . writeFileSync ( path . join ( dir , 'packages' , 'foo' , 'package.json' ) , `{}` ) ;
@@ -114,7 +113,7 @@ test('should generate in the root of pnpm workspace', async ({ run, packageManag
114
113
expect ( fs . existsSync ( path . join ( dir , 'playwright.config.ts' ) ) ) . toBeTruthy ( ) ;
115
114
} ) ;
116
115
117
- test ( 'should generate in the root of yarn workspaces' , async ( { run, packageManager } ) => {
116
+ test ( 'should generate in the root of yarn workspaces' , async ( { run, packageManager, exec } ) => {
118
117
test . skip ( packageManager !== 'yarn-berry' && packageManager !== 'yarn-classic' ) ;
119
118
120
119
const dir = test . info ( ) . outputDir ;
@@ -128,9 +127,9 @@ test('should generate in the root of yarn workspaces', async ({ run, packageMana
128
127
for ( const pkg of [ 'foo' , 'bar' ] ) {
129
128
const packageDir = path . join ( dir , 'packages' , pkg ) ;
130
129
fs . mkdirSync ( packageDir , { recursive : true } ) ;
131
- childProcess . execSync ( `yarn init -y` , { cwd : packageDir } ) ;
130
+ await exec ( `yarn` , [ ' init' , '-y' ] , { cwd : packageDir } ) ;
132
131
}
133
- childProcess . execSync ( `yarn install` , { cwd : dir , stdio : 'inherit' , env : { ...process . env , YARN_ENABLE_IMMUTABLE_INSTALLS : 'false' , YARN_ENABLE_HARDENED_MODE : '0' } } ) ;
132
+ await exec ( `yarn` , [ ' install' ] , { cwd : dir , env : { ...process . env , YARN_ENABLE_IMMUTABLE_INSTALLS : 'false' , YARN_ENABLE_HARDENED_MODE : '0' } } ) ;
134
133
135
134
await run ( [ ] , { installGitHubActions : false , testDir : 'tests' , language : 'TypeScript' , installPlaywrightDependencies : false , installPlaywrightBrowsers : false } ) ;
136
135
assertLockFilesExist ( dir , packageManager ) ;
@@ -170,14 +169,14 @@ test('should install with "npm i" in GHA when using npm with package-lock disabl
170
169
expect ( workflowContent ) . not . toContain ( 'run: npm ci' ) ;
171
170
} ) ;
172
171
173
- test ( 'is proper yarn classic' , async ( { packageManager } ) => {
172
+ test ( 'is proper yarn classic' , async ( { packageManager, exec } ) => {
174
173
test . skip ( packageManager !== 'yarn-classic' ) ;
175
- fs . mkdirSync ( test . info ( ) . outputDir ) ;
176
- expect ( childProcess . execSync ( 'yarn --version' , { encoding : 'utf-8' , cwd : test . info ( ) . outputDir } ) ) . toMatch ( / ^ 1 \. / ) ;
174
+ const result = await exec ( 'yarn --version' , [ ] , { cwd : test . info ( ) . outputDir , shell : true } ) ;
175
+ expect ( result . stdout ) . toMatch ( / ^ 1 \. / ) ;
177
176
} ) ;
178
177
179
- test ( 'is proper yarn berry' , async ( { packageManager } ) => {
178
+ test ( 'is proper yarn berry' , async ( { packageManager, exec } ) => {
180
179
test . skip ( packageManager !== 'yarn-berry' ) ;
181
- fs . mkdirSync ( test . info ( ) . outputDir ) ;
182
- expect ( childProcess . execSync ( 'yarn --version' , { encoding : 'utf-8' , cwd : test . info ( ) . outputDir } ) ) . toMatch ( / ^ 4 \. / ) ;
180
+ const result = await exec ( 'yarn --version' , [ ] , { cwd : test . info ( ) . outputDir , shell : true } ) ;
181
+ expect ( result . stdout ) . toMatch ( / ^ 4 \. / ) ;
183
182
} ) ;
0 commit comments