Requirements
- TypeScript: Synpress requires TypeScript version 5.0.4 or higher.
- Synpress: While Synpress v4 aims for stability. Pinning a specific version of
@synthetixio/synpressin yourpackage.jsonis highly recommended to avoid unexpected issues from breaking changes. Use a specific version like"@synthetixio/synpress": "4.0.5"rather than"@synthetixio/synpress": "^4.0.0". - ESM: Synpress is now an ESM-only package. Don’t use
require()to import it, and make sure your nearestpackage.jsoncontains"type": "module".
Configuration (tsconfig.json)
For optimal type checking and developer experience, enable the strict compiler option in your tsconfig.json:
strict: true: This enables a wide range of type-checking rules that help catch errors early and improve code quality. It’s highly recommended for any TypeScript project.esModuleInterop: true: This setting improves the interoperability between the different modules and is mandatory for the latest versions of Synpress.targetandmodule: The settings you have are probably OK. If you are getting compilation errors, make sure, that the correct module is used."moduleResolution": "bundler": If you’re using a modern bundler (like Vite, Webpack, or Rollup),"bundler"is the recommended setting.
tsconfig.json (for a Playwright project):
include and files arrays, that will point to all relevant files.
Example tsconfig.json (for a Cypress project):
include and files arrays, that will point to all relevant files.
By following these guidelines, you’ll ensure that your Synpress project benefits from the full power of TypeScript, including strong type checking, autocompletion, and improved code maintainability.
