@cypress/vite-dev-server
Advanced tools
Comparing version 5.0.7 to 5.1.0
@@ -16,2 +16,10 @@ // This file is merged in a <script type=module> into index.html | ||
let devServerPublicPathBase = devServerPublicPathRoute | ||
// In the case the devServerPublicPathRoute is set to the root, make sure we configure the loaders correctly to load relative paths | ||
// This can be a case in vite 5 if a user wishes to have the same public path as their app (which is quite common) | ||
if (devServerPublicPathRoute === '') { | ||
devServerPublicPathBase = '.' | ||
} | ||
if (supportFile) { | ||
@@ -24,11 +32,18 @@ let supportRelativeToProjectRoot = supportFile.replace(projectRoot, '') | ||
supportRelativeToProjectRoot = supportFile.replace(platformProjectRoot, '') | ||
// Support relative path (as well as in some cases absolute path) lookup is done with unix style operators. | ||
supportRelativeToProjectRoot = supportRelativeToProjectRoot.replaceAll('\\', '/') | ||
} | ||
// We need a slash before /cypress/supportFile.js, this happens by default | ||
// with the current string replacement logic. | ||
// We need a slash before /cypress/supportFile.js if the devServerPublicPathRoute is populated, this happens by default | ||
// with the current string replacement logic. Otherwise, we need to specify the relative path to look up if devServerPublicPathRoute | ||
// is not defined as it would be in the base directory | ||
const relativeUrl = `${devServerPublicPathBase}${supportRelativeToProjectRoot}` | ||
importsToLoad.push({ | ||
load: () => import(`${devServerPublicPathRoute}${supportRelativeToProjectRoot}`), | ||
load: () => import(relativeUrl), | ||
absolute: supportFile, | ||
relative: supportRelativeToProjectRoot, | ||
relativeUrl: `${devServerPublicPathRoute}${supportRelativeToProjectRoot}`, | ||
relativeUrl, | ||
}) | ||
@@ -41,3 +56,3 @@ } | ||
const normalizedAbsolutePath = CypressInstance.spec.absolute.replace(/^\//, '') | ||
const testFileAbsolutePathRoute = `${devServerPublicPathRoute}/@fs/${normalizedAbsolutePath}` | ||
const testFileAbsolutePathRoute = `${devServerPublicPathBase}/@fs/${normalizedAbsolutePath}` | ||
@@ -44,0 +59,0 @@ /* Spec file import logic */ |
/// <reference types="cypress" /> | ||
/// <reference types="node" /> | ||
import type { UserConfig } from 'vite'; | ||
import type { UserConfig } from 'vite-5'; | ||
declare const ALL_FRAMEWORKS: readonly ["react", "vue"]; | ||
@@ -17,4 +17,4 @@ declare type ConfigHandler = UserConfig | (() => UserConfig | Promise<UserConfig>); | ||
export declare namespace devServer { | ||
var create: (devServerConfig: ViteDevServerConfig, vite: typeof import("vite")) => Promise<import("vite").ViteDevServer>; | ||
var create: (devServerConfig: ViteDevServerConfig, vite: typeof import("vite-5")) => Promise<import("vite-5").ViteDevServer>; | ||
} | ||
export {}; |
@@ -6,2 +6,3 @@ "use strict"; | ||
const debug_1 = tslib_1.__importDefault(require("debug")); | ||
const major_1 = tslib_1.__importDefault(require("semver/functions/major")); | ||
const getVite_1 = require("./getVite"); | ||
@@ -14,2 +15,10 @@ const resolveConfig_1 = require("./resolveConfig"); | ||
const vite = (0, getVite_1.getVite)(config); | ||
let majorVersion = undefined; | ||
if (vite.version) { | ||
majorVersion = (0, major_1.default)(vite.version); | ||
debug(`Found vite version v${majorVersion}`); | ||
} | ||
else { | ||
debug(`vite version not found`); | ||
} | ||
debug('Creating Vite Server'); | ||
@@ -16,0 +25,0 @@ const server = await devServer.create(config, vite); |
import type { ViteDevServerConfig } from './devServer'; | ||
export declare type Vite = typeof import('vite'); | ||
export declare type Vite = typeof import('vite-5'); | ||
export declare function getVite(config: ViteDevServerConfig): Vite; |
@@ -1,4 +0,4 @@ | ||
import type { Plugin } from 'vite'; | ||
import type { PluginOption } from 'vite-5'; | ||
import type { Vite } from '../getVite'; | ||
import type { ViteDevServerConfig } from '../devServer'; | ||
export declare const Cypress: (options: ViteDevServerConfig, vite: Vite) => Plugin; | ||
export declare const Cypress: (options: ViteDevServerConfig, vite: Vite) => PluginOption; |
@@ -1,4 +0,4 @@ | ||
import type { Plugin } from 'vite'; | ||
import type { PluginOption } from 'vite-5'; | ||
import type { Vite } from '../getVite'; | ||
import type { ViteDevServerConfig } from '../devServer'; | ||
export declare const CypressSourcemap: (options: ViteDevServerConfig, vite: Vite) => Plugin; | ||
export declare const CypressSourcemap: (options: ViteDevServerConfig, vite: Vite) => PluginOption; |
@@ -1,4 +0,4 @@ | ||
import type { InlineConfig } from 'vite'; | ||
import type { InlineConfig } from 'vite-5'; | ||
import type { ViteDevServerConfig } from './devServer'; | ||
import type { Vite } from './getVite'; | ||
export declare const createViteDevServerConfig: (config: ViteDevServerConfig, vite: Vite) => Promise<InlineConfig>; |
{ | ||
"name": "@cypress/vite-dev-server", | ||
"version": "5.0.7", | ||
"version": "5.1.0", | ||
"description": "Launches Vite Dev Server for Component Testing", | ||
@@ -9,9 +9,9 @@ "main": "index.js", | ||
"check-ts": "tsc --noEmit", | ||
"cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .", | ||
"cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome", | ||
"cypress:run-cypress-in-cypress": "cross-env CYPRESS_INTERNAL_E2E_TESTING_SELF_PARENT_PROJECT=1 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", | ||
"lint": "eslint --ext .js,.ts,.json, .", | ||
"test": "yarn test-unit", | ||
"test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js", | ||
"lint": "eslint --ext .js,.ts,.json, ." | ||
"watch": "tsc -w" | ||
}, | ||
@@ -26,2 +26,3 @@ "dependencies": { | ||
"chai": "^4.3.6", | ||
"decache": "^4.6.2", | ||
"dedent": "^0.7.0", | ||
@@ -31,4 +32,5 @@ "mocha": "^9.2.2", | ||
"ts-node": "^10.9.2", | ||
"vite": "4.3.2", | ||
"vite-plugin-inspect": "0.7.24" | ||
"vite-4": "npm:vite@^4.5.2", | ||
"vite-5": "npm:vite@^5.2.8", | ||
"vite-plugin-inspect": "0.8.4" | ||
}, | ||
@@ -35,0 +37,0 @@ "files": [ |
@@ -59,2 +59,17 @@ # @cypress/vite-dev-server | ||
#### `devServerPublicPathRoute` for Vite v5 | ||
If using Vite version 5, setting `devServerPublicPathRoute` may be needed if directly referencing public path url assets in components under test. This is due to Cypress using its own public path, `/__cypress/src`, when running component tests. This can be configured within the `component` namespace below if you wish you set your public path to be the same as your app: | ||
```ts | ||
import { defineConfig } from 'cypress' | ||
export default defineConfig({ | ||
component: { | ||
// If wanting a publicPath the same as the default in Vite 5 | ||
devServerPublicPathRoute: '' | ||
} | ||
}) | ||
``` | ||
## License | ||
@@ -66,2 +81,2 @@ | ||
## [Changelog](./CHANGELOG.md) | ||
## [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
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
30351
512
80
9