Skip to content

Commit

Permalink
Fix tsconfig for test/ directory (#68346)
Browse files Browse the repository at this point in the history
* Add @types/node for test/ directory files

* Update tsconfig for e2e and performance test directories

* Add test/e2e and test/performance to root tsconfig references

* Expect TS error

* Remove declaration files

* Clean up tsconfig

* Use @types/node v 20

* Use a hack instead of ts-expect-error
  • Loading branch information
manzoorwanijk authored Dec 27, 2024
1 parent 80e7991 commit f1fadbb
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 88 deletions.
153 changes: 78 additions & 75 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"@types/estree": "1.0.5",
"@types/istanbul-lib-report": "3.0.0",
"@types/mime": "2.0.3",
"@types/node": "20.17.10",
"@types/npm-package-arg": "6.1.1",
"@types/prettier": "2.4.4",
"@types/qs": "6.9.7",
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { defineConfig, devices } from '@playwright/test';
/**
* WordPress dependencies
*/
const baseConfig = require( '@wordpress/scripts/config/playwright.config' );
import baseConfig from '@wordpress/scripts/config/playwright.config.js';

const config = defineConfig( {
...baseConfig,
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/specs/interactivity/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export const test = base.extend< Fixtures >( {
async ( { requestUtils }, use ) => {
await use( new InteractivityUtils( { requestUtils } ) );
},
// @ts-ignore: The required type is 'test', but can be 'worker' too. See
// This is a hack, 'worker' is a valid value but the type is wrong.
// https://playwright.dev/docs/test-fixtures#worker-scoped-fixtures
{ scope: 'worker' },
{ scope: 'worker' as 'test' },
],
} );
8 changes: 4 additions & 4 deletions test/e2e/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"checkJs": false,
"noEmit": true,
"emitDeclarationOnly": false,
"allowJs": true,
"checkJs": false
"rootDir": ".",
"types": [ "node" ]
},
"include": [ "**/*" ],
"include": [ "." ],
"exclude": []
}
2 changes: 1 addition & 1 deletion test/performance/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { defineConfig } from '@playwright/test';
/**
* WordPress dependencies
*/
const baseConfig = require( '@wordpress/scripts/config/playwright.config' );
import baseConfig from '@wordpress/scripts/config/playwright.config.js';

process.env.ASSETS_PATH = path.join( __dirname, 'assets' );

Expand Down
8 changes: 4 additions & 4 deletions test/performance/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"checkJs": false,
"noEmit": true,
"emitDeclarationOnly": false,
"allowJs": true,
"checkJs": false
"rootDir": ".",
"types": [ "node" ]
},
"include": [ "**/*" ],
"include": [ "." ],
"exclude": []
}
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
{ "path": "packages/url" },
{ "path": "packages/vips" },
{ "path": "packages/warning" },
{ "path": "packages/wordcount" }
{ "path": "packages/wordcount" },
{ "path": "test/e2e" },
{ "path": "test/performance" }
],
"files": []
}

1 comment on commit f1fadbb

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in f1fadbb.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/12516196842
📝 Reported issues:

Please sign in to comment.