-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 32325f1
Showing
37 changed files
with
5,472 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ | ||
|
||
dist/index.js | ||
dist/index.mjs | ||
!dist/noop.js | ||
!dist/noop.mjs | ||
|
||
.idea | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Compatibility | ||
|
||
## Forcing interaction | ||
[Cypress](https://docs.cypress.io/guides/core-concepts/interacting-with-elements#Forcing) | ||
[Playwright](https://playwright.dev/docs/input#forcing-the-click) | ||
|
||
Playwright force flag simply omits checks if element is visible and interactive, while cypress also emits an Event on the target element. Thus, in some cases, playwright action with `force` flag enabled, won't actually do anything. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) Solant | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# playwright-cypress-adapter | ||
|
||
A brief description of what this project does and who it's for | ||
|
||
## Usage | ||
|
||
Install module with you favorite package manager | ||
|
||
```shell | ||
# pnpm | ||
pnpm add -D playwright-cypress-adapter | ||
|
||
# npm | ||
npm install -D playwright-test-adapter | ||
|
||
# yarn | ||
yarn add -D playwright-test-adapter | ||
``` | ||
|
||
Change playwright config to use cypress test cases | ||
|
||
```javascript | ||
// playwright.config.ts | ||
import { defineConfig } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
// ... | ||
testMatch: /.*cy.js/, | ||
}); | ||
``` | ||
|
||
Prepend your cypress test cases with | ||
|
||
```javascript | ||
// my-test-case.cy.js | ||
import { setup } from 'playwright-cypress-adapter'; | ||
|
||
setup(); | ||
``` | ||
|
||
And now you can run your tests with playwright. Check project [playwright.config.ts](./playwright.config.ts) | ||
and [package.json](./package.json) scripts to see additional configurations. | ||
|
||
## FAQ | ||
|
||
#### What commands are supported? | ||
|
||
Currently, adapter can successfully translate basic `todo.cy.js` test case into playwright test runner. This *might* be | ||
enough for simple projects, but I highly doubt so. If you find this project useful, make sure to star it and provide the | ||
feedback on what cypress actions are needed for your use cases. | ||
|
||
#### Can I still run modified test cases in cypress? | ||
|
||
Yes, project uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to | ||
provide [mocked](./dist/noop.js) module for cypress that doesn't modify any globals. | ||
|
||
#### Are there any compatibility issues? | ||
|
||
Yes, some APIs with similar names are very different between cypress and playwright. | ||
See [compatibility](./COMPATIBILITY.md) notes. | ||
|
||
#### Are you copying cypress source code? | ||
|
||
No cypress source code is copied. But for the testing purposes project uses cypress basic examples. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
exports.setup = function () { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export function setup() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import tseslint from 'typescript-eslint'; | ||
import stylistic from '@stylistic/eslint-plugin'; | ||
import airbnb from 'eslint-stylistic-airbnb'; | ||
|
||
export default [ | ||
airbnb, | ||
...tseslint.configs.recommended, | ||
{ | ||
files: ['**/*.{js,mjs,cjs,ts}'], | ||
plugins: { | ||
'@stylistic': stylistic, | ||
}, | ||
}, | ||
{ | ||
ignores: ['tests/*', 'dist/*'], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "playwright-cypress-adapter", | ||
"version": "0.1.0", | ||
"description": "Run cypress test cases in playwright as they are", | ||
"type": "module", | ||
"scripts": { | ||
"build": "rollup --config", | ||
"test": "pnpm run lint && pnpm run test:unit && pnpm run test:e2e", | ||
"test:unit": "vitest run", | ||
"test:e2e": "playwright test", | ||
"playwright:ui": "playwright test --ui", | ||
"lint": "eslint", | ||
"lint:fix": "eslint --fix", | ||
"release": "pnpm test && pnpm build && pnpm changelogen --release --push && pnpm publish" | ||
}, | ||
"exports": { | ||
"import": { | ||
"browser": "./dist/noop.mjs", | ||
"default": "./dist/index.mjs" | ||
}, | ||
"require": { | ||
"browser": "./dist/noop.js", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"cypress", | ||
"playwright", | ||
"automation", | ||
"browser", | ||
"e2e" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/Solant/playwright-cypress-adapter/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Solant/playwright-cypress-adapter.git" | ||
}, | ||
"license": "MIT", | ||
"packageManager": "[email protected]+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e", | ||
"devDependencies": { | ||
"@stylistic/eslint-plugin": "^2.9.0", | ||
"@types/node": "^22.4.2", | ||
"changelogen": "^0.5.7", | ||
"eslint": "^9.12.0", | ||
"eslint-stylistic-airbnb": "^2.0.0", | ||
"rollup": "^4.24.0", | ||
"rollup-plugin-typescript2": "^0.36.0", | ||
"typescript": "^5.6.2", | ||
"typescript-eslint": "^8.8.0", | ||
"vitest": "^2.1.1" | ||
}, | ||
"peerDependencies": { | ||
"@playwright/test": "^1.46.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
testDir: 'tests', | ||
testMatch: /.*cy.ts/, | ||
fullyParallel: true, | ||
forbidOnly: !!process.env.CI, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
}); |
Oops, something went wrong.