@cypress/vite-dev-server
Advanced tools
Comparing version 2.2.3 to 3.0.0
@@ -0,1 +1,46 @@ | ||
# [@cypress/vite-dev-server-v3.0.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.2.3...@cypress/vite-dev-server-v3.0.0) (2022-06-13) | ||
### Bug Fixes | ||
* issue with compilation failures in component testing ([#21599](https://github.com/cypress-io/cypress/issues/21599)) ([f2bce02](https://github.com/cypress-io/cypress/commit/f2bce02f5dcab7a73a2a1b8e102518d706a29c25)) | ||
* restart dev-server on config change ([#21212](https://github.com/cypress-io/cypress/issues/21212)) ([00a0f5a](https://github.com/cypress-io/cypress/commit/00a0f5a0e905fdfe5ef9f8ba71f915ed20ca4b72)) | ||
* sanitize internal vite plugins ([#22055](https://github.com/cypress-io/cypress/issues/22055)) ([3b5a245](https://github.com/cypress-io/cypress/commit/3b5a245ec4aa9bf9f348fbc4bc2f0decc7c4a692)) | ||
* supportFile path and supportFile false for vite on windows ([#21156](https://github.com/cypress-io/cypress/issues/21156)) ([dd180c8](https://github.com/cypress-io/cypress/commit/dd180c89b27546b0c96cc3f4fb4e75d983c8003e)) | ||
* UNIFY-1774 error if component config is not sourced for webpack/vite ([#21563](https://github.com/cypress-io/cypress/issues/21563)) ([566a7b1](https://github.com/cypress-io/cypress/commit/566a7b1feb0fc1a8f1ccf83a23d8ad7a94409a6b)) | ||
* update scaffold template to use correct path ([#20047](https://github.com/cypress-io/cypress/issues/20047)) ([6e80359](https://github.com/cypress-io/cypress/commit/6e803597a379222cf936e5977c8314d693ee1912)) | ||
* use resolved port for vite ([#21490](https://github.com/cypress-io/cypress/issues/21490)) ([630e422](https://github.com/cypress-io/cypress/commit/630e4220ca5ebbaa8c39044b86d434510b3a0f1b)) | ||
* wire up scaffolded indexHtml to dev servers ([#20453](https://github.com/cypress-io/cypress/issues/20453)) ([3a8797e](https://github.com/cypress-io/cypress/commit/3a8797e54db9fd0ef93a14ddc71c138ba8251e53)) | ||
### chore | ||
* prep npm packages for use with Cypress v10 ([b924d08](https://github.com/cypress-io/cypress/commit/b924d086ee2e2ccc93303731e001b2c9e9d0af17)) | ||
### Features | ||
* add devServer to config file ([#18962](https://github.com/cypress-io/cypress/issues/18962)) ([2573375](https://github.com/cypress-io/cypress/commit/2573375b5b6616efd2d213a94cd55fd8e0385864)) | ||
* Add typings for new devServer config ([#18797](https://github.com/cypress-io/cypress/issues/18797)) ([e018a14](https://github.com/cypress-io/cypress/commit/e018a14c211bfcbdc4568a9a737f14f5c1686e35)) | ||
* Deprecate run-ct / open-ct, and update all examples to use --ct instead ([#18422](https://github.com/cypress-io/cypress/issues/18422)) ([196e8f6](https://github.com/cypress-io/cypress/commit/196e8f62cc6d27974f235945cb5700624b3dae41)) | ||
* improved DX and support for running component and e2e tests w/ gulp ([#18135](https://github.com/cypress-io/cypress/issues/18135)) ([d39b169](https://github.com/cypress-io/cypress/commit/d39b1694aac19fdcf557236ac421e2cc1c45da8b)) | ||
* index.html configurability and storybook support ([#18242](https://github.com/cypress-io/cypress/issues/18242)) ([745b3ac](https://github.com/cypress-io/cypress/commit/745b3ac4518302983522daedf817623334feae5b)) | ||
* merging / delegating remote queries to cloud schema ([#17875](https://github.com/cypress-io/cypress/issues/17875)) ([94541d4](https://github.com/cypress-io/cypress/commit/94541d4f18591e8fa4b8702c39e92b0a7238aa5d)) | ||
* remove testFiles reference ([#20565](https://github.com/cypress-io/cypress/issues/20565)) ([5670344](https://github.com/cypress-io/cypress/commit/567034459089d9d53dfab5556cb9369fb335c3db)) | ||
* Set up cypress in cypress ([#19602](https://github.com/cypress-io/cypress/issues/19602)) ([ed51bcb](https://github.com/cypress-io/cypress/commit/ed51bcbdda480f90bef557f06c297098f1897499)) | ||
* Structuring context & schema so it can be used on the client ([#17489](https://github.com/cypress-io/cypress/issues/17489)) ([e2f395e](https://github.com/cypress-io/cypress/commit/e2f395e330f384993ed1116469102a5315a21270)), closes [#17551](https://github.com/cypress-io/cypress/issues/17551) | ||
* support specPattern, deprecate integrationFolder and componentFolder ([#19319](https://github.com/cypress-io/cypress/issues/19319)) ([792980a](https://github.com/cypress-io/cypress/commit/792980ac12746ef47b9c944ebe4c6c353a187ab2)) | ||
* swap the #__cy_root id selector to become data-cy-root for component mounting ([#20951](https://github.com/cypress-io/cypress/issues/20951)) ([0e7b555](https://github.com/cypress-io/cypress/commit/0e7b555f93fb403f431c5de4a07ae7ad6ac89ba2)) | ||
* Use .config files ([#18578](https://github.com/cypress-io/cypress/issues/18578)) ([081dd19](https://github.com/cypress-io/cypress/commit/081dd19cc6da3da229a7af9c84f62730c85a5cd6)) | ||
* use devServer instad of startDevServer ([#20092](https://github.com/cypress-io/cypress/issues/20092)) ([8a6768f](https://github.com/cypress-io/cypress/commit/8a6768fee6f46b908c5a9daf23da8b804a6c627f)) | ||
* Use plugins on config files ([#18798](https://github.com/cypress-io/cypress/issues/18798)) ([bb8251b](https://github.com/cypress-io/cypress/commit/bb8251b752ac44f1184f9160194cf12d41fc867f)) | ||
* use supportFile by testingType ([#19364](https://github.com/cypress-io/cypress/issues/19364)) ([0366d4f](https://github.com/cypress-io/cypress/commit/0366d4fa8971e5e5189c6fd6450cc3c8d72dcfe1)) | ||
* vue-cli and nuxt preset for CT object API architecture ([#20956](https://github.com/cypress-io/cypress/issues/20956)) ([57659c4](https://github.com/cypress-io/cypress/commit/57659c42468591265143aae2ff06bae4e440085f)) | ||
* **unify:** removing prism and adding infrastructure for shiki ([#18514](https://github.com/cypress-io/cypress/issues/18514)) ([9a2e550](https://github.com/cypress-io/cypress/commit/9a2e55071d5b6dcfd97ff750b80548b834b94d30)) | ||
### BREAKING CHANGES | ||
* new version of packages for Cypress v10 | ||
# [@cypress/vite-dev-server-v2.2.3](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.2.2...@cypress/vite-dev-server-v2.2.3) (2022-05-10) | ||
@@ -2,0 +47,0 @@ |
// This file is merged in a <script type=module> into index.html | ||
// it will be used to load and kick start the selected spec | ||
import specLoaders from 'cypress:spec-loaders' | ||
import { hasSupportPath, originAutUrl } from 'cypress:config' | ||
const specPath = window.location.pathname.replace(originAutUrl, '') | ||
const CypressInstance = window.Cypress = parent.Cypress | ||
const specLoader = specLoaders[specPath] | ||
const importsToLoad = [specLoader || (() => import(/* @vite-ignore */ specPath))] | ||
const importsToLoad = [] | ||
if (hasSupportPath) { | ||
importsToLoad.unshift(() => import('cypress:support-path')) | ||
/* Support file import logic, this should be removed once we | ||
* are able to return relative paths from the supportFile | ||
* Jira #UNIFY-1260 | ||
*/ | ||
const supportFile = CypressInstance.config('supportFile') | ||
const projectRoot = CypressInstance.config('projectRoot') | ||
const devServerPublicPathRoute = CypressInstance.config('devServerPublicPathRoute') | ||
if (supportFile) { | ||
let supportRelativeToProjectRoot = supportFile.replace(projectRoot, '') | ||
if (CypressInstance.config('platform') === 'win32') { | ||
const platformProjectRoot = projectRoot.replaceAll('/', '\\') | ||
supportRelativeToProjectRoot = supportFile.replace(platformProjectRoot, '') | ||
} | ||
// We need a slash before /cypress/supportFile.js, this happens by default | ||
// with the current string replacement logic. | ||
importsToLoad.push(() => import(`${devServerPublicPathRoute}${supportRelativeToProjectRoot}`)) | ||
} | ||
const CypressInstance = window.Cypress = parent.Cypress | ||
/* Spec file import logic */ | ||
// We need a slash before /src/my-spec.js, this does not happen by default. | ||
importsToLoad.push(() => import(`${devServerPublicPathRoute}/${CypressInstance.spec.relative}`)) | ||
@@ -17,0 +34,0 @@ if (!CypressInstance) { |
@@ -1,8 +0,3 @@ | ||
/// <reference types="cypress" /> | ||
import { InlineConfig } from 'vite'; | ||
import { StartDevServerOptions } from './resolveServerConfig'; | ||
export { StartDevServerOptions }; | ||
export declare function startDevServer(startDevServerArgs: StartDevServerOptions): Promise<Cypress.ResolvedDevServerConfig>; | ||
export declare type CypressViteDevServerConfig = Omit<InlineConfig, 'base' | 'root'>; | ||
export declare function devServer(cypressDevServerConfig: Cypress.DevServerConfig, devServerConfig?: CypressViteDevServerConfig): Promise<Cypress.ResolvedDevServerConfig>; | ||
export declare function defineDevServerConfig(devServerConfig: CypressViteDevServerConfig): CypressViteDevServerConfig; | ||
import { devServer } from './devServer'; | ||
export { devServer }; | ||
export default devServer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defineDevServerConfig = exports.devServer = exports.startDevServer = void 0; | ||
const debug_1 = require("debug"); | ||
const vite_1 = require("vite"); | ||
const resolveServerConfig_1 = require("./resolveServerConfig"); | ||
const debug = (0, debug_1.debug)('cypress:vite-dev-server:vite'); | ||
async function startDevServer(startDevServerArgs) { | ||
if (!startDevServerArgs.viteConfig) { | ||
debug('User did not pass in any Vite dev server configuration'); | ||
startDevServerArgs.viteConfig = {}; | ||
} | ||
debug('starting vite dev server'); | ||
const resolvedConfig = await (0, resolveServerConfig_1.resolveServerConfig)(startDevServerArgs); | ||
const port = resolvedConfig.server.port; | ||
const viteDevServer = await (0, vite_1.createServer)(resolvedConfig); | ||
await viteDevServer.listen(); | ||
debug('Component testing vite server started on port', port); | ||
return { port, close: viteDevServer.close }; | ||
} | ||
exports.startDevServer = startDevServer; | ||
function devServer(cypressDevServerConfig, devServerConfig) { | ||
return startDevServer({ options: cypressDevServerConfig, viteConfig: devServerConfig }); | ||
} | ||
exports.devServer = devServer; | ||
function defineDevServerConfig(devServerConfig) { | ||
return devServerConfig; | ||
} | ||
exports.defineDevServerConfig = defineDevServerConfig; | ||
exports.devServer = void 0; | ||
const devServer_1 = require("./devServer"); | ||
Object.defineProperty(exports, "devServer", { enumerable: true, get: function () { return devServer_1.devServer; } }); | ||
exports.default = devServer_1.devServer; |
{ | ||
"name": "@cypress/vite-dev-server", | ||
"version": "2.2.3", | ||
"version": "3.0.0", | ||
"description": "Launches Vite Dev Server for Component Testing", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "tsc", | ||
"build-prod": "tsc", | ||
"cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}", | ||
"cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}", | ||
"cy:run-signature": "yarn cy:run --config=\"{\\\"pluginsFile\\\":\\\"cypress/new-signature/plugins.js\\\"}\"", | ||
"test": "yarn cy:run && yarn cy:run-signature", | ||
"watch": "tsc -w" | ||
"build": "tsc || echo 'built, with type errors'", | ||
"build-prod": "tsc || echo 'built, with type errors'", | ||
"check-ts": "tsc --noEmit", | ||
"cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", | ||
"cypress:run-cypress-in-cypress": "cross-env HTTP_PROXY_TARGET_FOR_ORIGIN_REQUESTS=http://localhost:4455 CYPRESS_REMOTE_DEBUGGING_PORT=6666 TZ=America/New_York", | ||
"cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", | ||
"watch": "tsc -w", | ||
"test": "yarn test-unit", | ||
"test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js" | ||
}, | ||
"dependencies": { | ||
"debug": "^4.3.2", | ||
"get-port": "^5.1.1" | ||
"debug": "4.3.3", | ||
"find-up": "6.3.0", | ||
"local-pkg": "0.4.1", | ||
"pathe": "0.2.0" | ||
}, | ||
"devDependencies": { | ||
"@cypress/react": "0.0.0-development", | ||
"@cypress/vue": "0.0.0-development", | ||
"@testing-library/cypress": "7.0.4", | ||
"@vitejs/plugin-vue": "1.2.0", | ||
"@vue/compiler-sfc": "3.0.9", | ||
"cypress": "0.0.0-development", | ||
"mocha-junit-reporter": "^2.0.0", | ||
"mocha-multi-reporters": "^1.5.1", | ||
"react": "17.0.2", | ||
"vite": "2.2.3", | ||
"vue": "3.0.11" | ||
"chai": "^4.3.6", | ||
"dedent": "^0.7.0", | ||
"mocha": "^9.2.2", | ||
"sinon": "^13.0.1", | ||
"ts-node": "^10.2.1", | ||
"vite": "2.9.0-beta.3", | ||
"vite-plugin-inspect": "0.4.3" | ||
}, | ||
"peerDependencies": { | ||
"vite": ">= 2.1.3" | ||
}, | ||
"files": [ | ||
@@ -36,0 +33,0 @@ "dist", |
# @cypress/vite-dev-server | ||
> ⚡️ + 🌲 Cypress Component Testing w/ Vite | ||
Implements the APIs for the object-syntax of the Cypress Component-testing "vite dev server". | ||
To install vite in you component testing environment, | ||
1. Install it `yarn add @cypress/vite-dev-server` | ||
2. Add it to `cypress/plugins/index.js` | ||
Object syntax: | ||
```js | ||
import { startDevServer } from '@cypress/vite-dev-server' | ||
```ts | ||
import { defineConfig } from 'cypress' | ||
module.exports = (on, config) => { | ||
on('dev-server:start', async (options) => startDevServer({ options })) | ||
return config | ||
} | ||
export default defineConfig({ | ||
component: { | ||
devServer: { | ||
framework: 'create-react-app', | ||
bundler: 'vite', | ||
// viteConfig?: Will try to infer, if passed it will be used as is | ||
} | ||
} | ||
}) | ||
``` | ||
# @cypress/webpack-dev-server | ||
Function syntax: | ||
> **Note** this package is not meant to be used outside of cypress component testing. | ||
```ts | ||
import { devServer } from '@cypress/vite-dev-server' | ||
import { defineConfig } from 'cypress' | ||
Install `@cypress/vue` or `@cypress/react` to get this package working properly | ||
export default defineConfig({ | ||
component: { | ||
devServer(cypressConfig) { | ||
return devServer({ | ||
cypressConfig, | ||
framework: 'react', | ||
viteConfig: require('./vite.config.js') | ||
}) | ||
} | ||
} | ||
}) | ||
``` | ||
## Architecture | ||
### Cypress server | ||
There should be a single publicly-exported entrypoint for the module, `devServer`, all other types and functions should be considered internal/implementation details, and types stripped from the output. | ||
- Every HTTP request goes to the cypress server which returns an html page. We call "TOP" because of its name in the dev tools | ||
This page | ||
- renders the list of spec files | ||
- And the timetraveling command log | ||
- Finally, it renders an AUT Iframe. this iframe calls a url that has 2 parts concatenated. | ||
- a prefix: `__cypress/iframes/` | ||
- the path to the current. For example: `src/components/button.spec.tsx` | ||
- In the cypress server, calls prefixed with `__cypress/iframes/...` will be passed to the dev-server as `__cypress/src/index.html` | ||
- Every call with the prefix `__cypress/src/` will be passed to the dev-server to deal as is, without changes. | ||
The `devServer` will first source the modules from the user's project, falling back to our own bundled versions of libraries. This ensures that the user has installed the current modules, and throws an error if the user does not have the library installed. | ||
### Dev-server | ||
From there, we check the "framework" field to source or define any known vite transforms to aid in the compilation. | ||
- Responds to every query with the prefix `__cypress/src/` (base path should be this prefix). | ||
- Responds to `__cypress/src/index.html` with an html page. | ||
This page | ||
- will contain an element `<div id="__cy_root"></div>`. Tis will be used by mount function to mount the app containing the components we want. | ||
- will load support files | ||
- will load the current spec from the url | ||
- will start the test when both files are done loading | ||
- The server re-runs the tests as soon as the current spec or any dependency is updated by calling an event `devServerEvents.emit('dev-server:compile:success')` | ||
We then merge the sourced config with the user's vite config, and layer on our own transforms, and provide this to a vite instance. The vite instance used to create a vite-dev-server, which is returned. | ||
## Vite dev server | ||
- Takes the users `vite.config` and adds base of `__cypress/src/` and a cypress vite plugin. | ||
- The cypress plugin takes care of | ||
- responding to the index.html query with an html page | ||
- restarting the tests when files are changed | ||
- The HTML page calls a script that loads support file and the specs using a native `import()` function | ||
- Then triggers the loaded tests | ||
Vite is responsible for compiling and bundling all the files. We use its error overlay to display any transpiling error. | ||
Only runtime errors have to be handled through cypress | ||
## Changelog | ||
[Changelog](./CHANGELOG.md) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
43495
7
22
408
4
53
6
1
+ Addedfind-up@6.3.0
+ Addedlocal-pkg@0.4.1
+ Addedpathe@0.2.0
+ Addeddebug@4.3.3(transitive)
+ Addedfind-up@6.3.0(transitive)
+ Addedlocal-pkg@0.4.1(transitive)
+ Addedlocate-path@7.2.0(transitive)
+ Addedms@2.1.2(transitive)
+ Addedp-limit@4.0.0(transitive)
+ Addedp-locate@6.0.0(transitive)
+ Addedpath-exists@5.0.0(transitive)
+ Addedpathe@0.2.0(transitive)
+ Addedyocto-queue@1.1.1(transitive)
- Removedget-port@^5.1.1
- Removed@esbuild/aix-ppc64@0.21.5(transitive)
- Removed@esbuild/android-arm@0.21.5(transitive)
- Removed@esbuild/android-arm64@0.21.5(transitive)
- Removed@esbuild/android-x64@0.21.5(transitive)
- Removed@esbuild/darwin-arm64@0.21.5(transitive)
- Removed@esbuild/darwin-x64@0.21.5(transitive)
- Removed@esbuild/freebsd-arm64@0.21.5(transitive)
- Removed@esbuild/freebsd-x64@0.21.5(transitive)
- Removed@esbuild/linux-arm@0.21.5(transitive)
- Removed@esbuild/linux-arm64@0.21.5(transitive)
- Removed@esbuild/linux-ia32@0.21.5(transitive)
- Removed@esbuild/linux-loong64@0.21.5(transitive)
- Removed@esbuild/linux-mips64el@0.21.5(transitive)
- Removed@esbuild/linux-ppc64@0.21.5(transitive)
- Removed@esbuild/linux-riscv64@0.21.5(transitive)
- Removed@esbuild/linux-s390x@0.21.5(transitive)
- Removed@esbuild/linux-x64@0.21.5(transitive)
- Removed@esbuild/netbsd-x64@0.21.5(transitive)
- Removed@esbuild/openbsd-x64@0.21.5(transitive)
- Removed@esbuild/sunos-x64@0.21.5(transitive)
- Removed@esbuild/win32-arm64@0.21.5(transitive)
- Removed@esbuild/win32-ia32@0.21.5(transitive)
- Removed@esbuild/win32-x64@0.21.5(transitive)
- Removed@rollup/rollup-android-arm-eabi@4.27.4(transitive)
- Removed@rollup/rollup-android-arm64@4.27.4(transitive)
- Removed@rollup/rollup-darwin-arm64@4.27.4(transitive)
- Removed@rollup/rollup-darwin-x64@4.27.4(transitive)
- Removed@rollup/rollup-freebsd-arm64@4.27.4(transitive)
- Removed@rollup/rollup-freebsd-x64@4.27.4(transitive)
- Removed@rollup/rollup-linux-arm-gnueabihf@4.27.4(transitive)
- Removed@rollup/rollup-linux-arm-musleabihf@4.27.4(transitive)
- Removed@rollup/rollup-linux-arm64-gnu@4.27.4(transitive)
- Removed@rollup/rollup-linux-arm64-musl@4.27.4(transitive)
- Removed@rollup/rollup-linux-powerpc64le-gnu@4.27.4(transitive)
- Removed@rollup/rollup-linux-riscv64-gnu@4.27.4(transitive)
- Removed@rollup/rollup-linux-s390x-gnu@4.27.4(transitive)
- Removed@rollup/rollup-linux-x64-gnu@4.27.4(transitive)
- Removed@rollup/rollup-linux-x64-musl@4.27.4(transitive)
- Removed@rollup/rollup-win32-arm64-msvc@4.27.4(transitive)
- Removed@rollup/rollup-win32-ia32-msvc@4.27.4(transitive)
- Removed@rollup/rollup-win32-x64-msvc@4.27.4(transitive)
- Removed@types/estree@1.0.6(transitive)
- Removeddebug@4.3.7(transitive)
- Removedesbuild@0.21.5(transitive)
- Removedfsevents@2.3.3(transitive)
- Removedget-port@5.1.1(transitive)
- Removedms@2.1.3(transitive)
- Removednanoid@3.3.7(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedpostcss@8.4.49(transitive)
- Removedrollup@4.27.4(transitive)
- Removedsource-map-js@1.2.1(transitive)
- Removedvite@5.4.11(transitive)
Updateddebug@4.3.3