Skip to content

Commit 8c70392

Browse files
feat: added cypress framework api
Co-authored-by: Jordan <[email protected]>
1 parent b969a61 commit 8c70392

File tree

9 files changed

+99
-20
lines changed

9 files changed

+99
-20
lines changed

apps/qwik-app/cypress.config.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
import { defineConfig } from 'cypress';
22

3-
export default defineConfig({
4-
component: {
5-
devServer: {
6-
bundler: 'vite',
7-
} as any,
8-
},
9-
});
3+
export default defineConfig({});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"autoprefixer": "^10.4.13",
3838
"commitizen": "^4.3.0",
3939
"commitlint": "^17.4.3",
40-
"cypress": "^12.5.1",
40+
"cypress": "12.8.1",
4141
"cz-conventional-changelog": "^3.3.0",
4242
"eslint": "8.36.0",
4343
"eslint-config-prettier": "8.6.0",
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { defineComponentFramework } from 'cypress';
2+
3+
const qwik: Cypress.CypressComponentDependency = {
4+
type: 'cypress-ct-qwik',
5+
name: 'Qwik',
6+
package: '@builder.io/qwik',
7+
installer: '@builder.io/qwik',
8+
description: 'The HTML-first framework',
9+
minVersion: '^0.19.2',
10+
};
11+
12+
const qwikCity: Cypress.CypressComponentDependency = {
13+
type: 'cypress-ct-qwik',
14+
name: 'Qwik City',
15+
package: '@builder.io/qwik-city',
16+
installer: '@builder.io/qwik-city',
17+
description: 'The meta-framework for Qwik',
18+
minVersion: '^0.4.0',
19+
};
20+
21+
export default defineComponentFramework({
22+
/**
23+
* This should match the `npm` package name.
24+
* The convention required to ensure your Definition is processed
25+
* by Cypress is `cypress-ct-*` for global packages, or
26+
* `@org/cypress-ct-*` for organization level packages.
27+
*/
28+
type: 'cypress-ct-qwik',
29+
30+
/**
31+
* The label that shows up when configuring Component Testing
32+
* for the first time.
33+
*/
34+
name: 'Qwik',
35+
36+
/**
37+
* Supported bundlers. Can be "webpack" and/or "vite".
38+
*/
39+
supportedBundlers: ['vite'],
40+
41+
/**
42+
* Used by Cypress to automatically detect the correct Framework Definition
43+
* based on the user's project.
44+
* In this example, if a module matching `solidDep`
45+
* is found in the user's project,
46+
* Solid.js will automatically be selected when configuring Component Testing.
47+
*/
48+
detectors: [qwik],
49+
50+
/**
51+
* Optionally, some conditional logic, based on whether
52+
* the user selected Vite or webpack.
53+
*/
54+
dependencies: (bundler) => {
55+
return [qwik, qwikCity];
56+
},
57+
});

packages/cypress-ct-qwik/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
"name": "cypress-ct-qwik",
33
"version": "0.0.6",
44
"type": "module",
5-
"exports": "./src/index.js",
5+
"exports": {
6+
"node": "definition.js",
7+
"require": "definition.js",
8+
"default": "./src/index.js"
9+
},
610
"dependencies": {
711
"@cypress/mount-utils": "^4.0.0"
812
},

packages/cypress-ct-qwik/project.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"projectType": "library",
66
"targets": {
77
"build": {
8+
"dependsOn": ["build-definition"],
89
"executor": "@nrwl/js:tsc",
910
"outputs": ["{options.outputPath}"],
1011
"options": {
@@ -25,6 +26,15 @@
2526
]
2627
}
2728
},
29+
"build-definition": {
30+
"executor": "@nrwl/js:tsc",
31+
"outputs": ["{options.outputPath}"],
32+
"options": {
33+
"outputPath": "dist/packages/cypress-ct-qwik",
34+
"main": "packages/cypress-ct-qwik/definition.ts",
35+
"tsConfig": "packages/cypress-ct-qwik/tsconfig.definition.json"
36+
}
37+
},
2838
"lint": {
2939
"executor": "@nrwl/linter:eslint",
3040
"outputs": ["{options.outputFile}"],
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "../../dist/out-tsc",
6+
"declaration": true,
7+
"types": ["node", "cypress"],
8+
"importHelpers": false
9+
},
10+
"include": ["definition.ts"]
11+
}

packages/cypress-ct-qwik/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
"references": [
1717
{
1818
"path": "./tsconfig.lib.json"
19+
},
20+
{
21+
"path": "./tsconfig.definition.json"
1922
}
2023
]
2124
}

packages/cypress-ct-qwik/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"types": ["node", "cypress"],
77
"importHelpers": false
88
},
9-
"include": ["src/**/*.ts", "src/lib/mount.tsx"],
9+
"include": ["src/**/*.ts", "src/lib/mount.tsx", "definition.ts"],
1010
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
1111
}

pnpm-lock.yaml

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)