@cypress/vite-dev-server 2.2.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -45
- package/client/initCypressTests.js +25 -7
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +11 -0
- package/dist/devServer.d.ts +17 -0
- package/dist/devServer.js +42 -0
- package/dist/getVite.d.ts +3 -0
- package/dist/getVite.js +20 -0
- package/dist/index.d.ts +3 -8
- package/dist/index.js +4 -20
- package/dist/plugins/cypress.d.ts +4 -0
- package/dist/plugins/cypress.js +138 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.js +5 -0
- package/dist/plugins/inspect.d.ts +3 -0
- package/dist/plugins/inspect.js +27 -0
- package/dist/resolveConfig.d.ts +3 -0
- package/dist/resolveConfig.js +92 -0
- package/package.json +22 -24
- package/CHANGELOG.md +0 -289
- package/dist/makeCypressPlugin.d.ts +0 -9
- package/dist/makeCypressPlugin.js +0 -123
- package/dist/startServer.d.ts +0 -16
- package/dist/startServer.js +0 -66
- package/index.html +0 -12
package/README.md
CHANGED
|
@@ -1,64 +1,65 @@
|
|
|
1
1
|
# @cypress/vite-dev-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Implements the APIs for the object-syntax of the Cypress Component-testing "vite dev server".
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
1. Install it `yarn add @cypress/vite-dev-server`
|
|
7
|
-
2. Add it to `cypress/plugins/index.js`
|
|
5
|
+
> **Note:** This package is bundled with the Cypress binary and should not need to be installed separately. See the [Component Framework Configuration Docs](https://docs.cypress.io/guides/component-testing/component-framework-configuration) for setting up component testing with vite. The `devServer` function signature is for advanced use-cases.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
import { startDevServer } from '@cypress/vite-dev-server'
|
|
7
|
+
Object syntax:
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
```ts
|
|
10
|
+
import { defineConfig } from 'cypress'
|
|
14
11
|
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
component: {
|
|
14
|
+
devServer: {
|
|
15
|
+
framework: 'create-react-app',
|
|
16
|
+
bundler: 'vite',
|
|
17
|
+
// viteConfig?: Will try to infer, if passed it will be used as is
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
})
|
|
17
21
|
```
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
Function syntax:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { devServer } from '@cypress/vite-dev-server'
|
|
27
|
+
import { defineConfig } from 'cypress'
|
|
28
|
+
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
component: {
|
|
31
|
+
devServer(devServerConfig) {
|
|
32
|
+
return devServer({
|
|
33
|
+
...devServerConfig,
|
|
34
|
+
framework: 'react',
|
|
35
|
+
viteConfig: require('./vite.config.js')
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
```
|
|
24
41
|
|
|
25
42
|
## Architecture
|
|
26
43
|
|
|
27
|
-
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
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.
|
|
28
47
|
|
|
29
|
-
|
|
30
|
-
This page
|
|
31
|
-
- renders the list of spec files
|
|
32
|
-
- And the timetraveling command log
|
|
33
|
-
- Finally, it renders an AUT Iframe. this iframe calls a url that has 2 parts concatenated.
|
|
34
|
-
- a prefix: `__cypress/iframes/`
|
|
35
|
-
- the path to the current. For example: `src/components/button.spec.tsx`
|
|
36
|
-
- In the cypress server, calls prefixed with `__cypress/iframes/...` will be passed to the dev-server as `__cypress/src/index.html`
|
|
37
|
-
- Every call with the prefix `__cypress/src/` will be passed to the dev-server to deal as is, without changes.
|
|
48
|
+
From there, we check the "framework" field to source or define any known vite transforms to aid in the compilation.
|
|
38
49
|
|
|
39
|
-
|
|
50
|
+
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.
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
- Responds to `__cypress/src/index.html` with an html page.
|
|
43
|
-
This page
|
|
44
|
-
- 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.
|
|
45
|
-
- will load support files
|
|
46
|
-
- will load the current spec from the url
|
|
47
|
-
- will start the test when both files are done loading
|
|
48
|
-
- 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')`
|
|
52
|
+
## Compatibility
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
| @cypress/vite-dev-server | cypress |
|
|
55
|
+
| ------------------------ | ------- |
|
|
56
|
+
| <= v2 | <= v9 |
|
|
57
|
+
| >= v3 | >= v10 |
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
- The cypress plugin takes care of
|
|
54
|
-
- responding to the index.html query with an html page
|
|
55
|
-
- restarting the tests when files are changed
|
|
56
|
-
- The HTML page calls a script that loads support file and the specs using a native `import()` function
|
|
57
|
-
- Then triggers the loaded tests
|
|
59
|
+
## License
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
Omly runtime errors have to be handled through cypress
|
|
61
|
+
[](https://github.com/cypress-io/cypress/blob/master/LICENSE)
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
This project is licensed under the terms of the [MIT license](/LICENSE).
|
|
63
64
|
|
|
64
|
-
[Changelog](./CHANGELOG.md)
|
|
65
|
+
## [Changelog](./CHANGELOG.md)
|
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
// This file is merged in a <script type=module> into index.html
|
|
2
2
|
// it will be used to load and kick start the selected spec
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const CypressInstance = window.Cypress = parent.Cypress
|
|
5
|
+
|
|
6
|
+
const importsToLoad = []
|
|
7
|
+
|
|
8
|
+
/* Support file import logic, this should be removed once we
|
|
9
|
+
* are able to return relative paths from the supportFile
|
|
10
|
+
* Jira #UNIFY-1260
|
|
11
|
+
*/
|
|
12
|
+
const supportFile = CypressInstance.config('supportFile')
|
|
13
|
+
const projectRoot = CypressInstance.config('projectRoot')
|
|
14
|
+
const devServerPublicPathRoute = CypressInstance.config('devServerPublicPathRoute')
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
if (supportFile) {
|
|
17
|
+
let supportRelativeToProjectRoot = supportFile.replace(projectRoot, '')
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
if (CypressInstance.config('platform') === 'win32') {
|
|
20
|
+
const platformProjectRoot = projectRoot.replaceAll('/', '\\')
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
supportRelativeToProjectRoot = supportFile.replace(platformProjectRoot, '')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// We need a slash before /cypress/supportFile.js, this happens by default
|
|
26
|
+
// with the current string replacement logic.
|
|
27
|
+
importsToLoad.push(() => import(`${devServerPublicPathRoute}${supportRelativeToProjectRoot}`))
|
|
13
28
|
}
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
/* Spec file import logic */
|
|
31
|
+
// We need a slash before /src/my-spec.js, this does not happen by default.
|
|
32
|
+
importsToLoad.push(() => import(`${devServerPublicPathRoute}/${CypressInstance.spec.relative}`))
|
|
16
33
|
|
|
17
34
|
if (!CypressInstance) {
|
|
18
35
|
throw new Error('Tests cannot run without a reference to Cypress!')
|
|
@@ -46,3 +63,4 @@ CypressInstance.on('test:before:run', () => {
|
|
|
46
63
|
|
|
47
64
|
// Make usage of node test plugins possible
|
|
48
65
|
window.global = window
|
|
66
|
+
window.process = typeof process !== 'undefined' ? process : {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const configFiles: string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configFiles = void 0;
|
|
4
|
+
exports.configFiles = [
|
|
5
|
+
'vite.config.ts',
|
|
6
|
+
'vite.config.js',
|
|
7
|
+
'vite.config.mjs',
|
|
8
|
+
'vite.config.cjs',
|
|
9
|
+
'vite.config.mts',
|
|
10
|
+
'vite.config.cts',
|
|
11
|
+
];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
declare const ALL_FRAMEWORKS: readonly ["react", "vue"];
|
|
4
|
+
export declare type ViteDevServerConfig = {
|
|
5
|
+
specs: Cypress.Spec[];
|
|
6
|
+
cypressConfig: Cypress.PluginConfigOptions;
|
|
7
|
+
devServerEvents: NodeJS.EventEmitter;
|
|
8
|
+
onConfigNotFound?: (devServer: 'vite', cwd: string, lookedIn: string[]) => void;
|
|
9
|
+
} & {
|
|
10
|
+
framework?: typeof ALL_FRAMEWORKS[number];
|
|
11
|
+
viteConfig?: unknown;
|
|
12
|
+
};
|
|
13
|
+
export declare function devServer(config: ViteDevServerConfig): Promise<Cypress.ResolvedDevServerConfig>;
|
|
14
|
+
export declare namespace devServer {
|
|
15
|
+
var create: (devServerConfig: ViteDevServerConfig, vite: typeof import("vite")) => Promise<import("vite").ViteDevServer>;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.devServer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
6
|
+
const getVite_1 = require("./getVite");
|
|
7
|
+
const resolveConfig_1 = require("./resolveConfig");
|
|
8
|
+
const debug = (0, debug_1.default)('cypress:vite-dev-server:devServer');
|
|
9
|
+
const ALL_FRAMEWORKS = ['react', 'vue'];
|
|
10
|
+
async function devServer(config) {
|
|
11
|
+
// This has to be the first thing we do as we need to source vite from their project's dependencies
|
|
12
|
+
const vite = (0, getVite_1.getVite)(config);
|
|
13
|
+
debug('Creating Vite Server');
|
|
14
|
+
const server = await devServer.create(config, vite);
|
|
15
|
+
debug('Vite server created');
|
|
16
|
+
await server.listen();
|
|
17
|
+
const { port } = server.config.server;
|
|
18
|
+
if (!port) {
|
|
19
|
+
throw new Error('Missing vite dev server port.');
|
|
20
|
+
}
|
|
21
|
+
debug('Successfully launched the vite server on port', port);
|
|
22
|
+
return {
|
|
23
|
+
port,
|
|
24
|
+
// Close is for unit testing only. We kill this child process which will handle the closing of the server
|
|
25
|
+
close(cb) {
|
|
26
|
+
return server.close().then(() => cb === null || cb === void 0 ? void 0 : cb()).catch(cb);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.devServer = devServer;
|
|
31
|
+
devServer.create = async function createDevServer(devServerConfig, vite) {
|
|
32
|
+
try {
|
|
33
|
+
const config = await (0, resolveConfig_1.createViteDevServerConfig)(devServerConfig, vite);
|
|
34
|
+
return await vite.createServer(config);
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
if (err instanceof Error) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
throw new Error(err);
|
|
41
|
+
}
|
|
42
|
+
};
|
package/dist/getVite.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getVite = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
6
|
+
const debug = (0, debug_1.default)('cypress:vite-dev-server:getVite');
|
|
7
|
+
// "vite-dev-server" is bundled in the binary, so we need to require.resolve "vite"
|
|
8
|
+
// from root of the active project since we don't bundle vite internally but rather
|
|
9
|
+
// use the version the user has installed
|
|
10
|
+
function getVite(config) {
|
|
11
|
+
try {
|
|
12
|
+
const viteImportPath = require.resolve('vite', { paths: [config.cypressConfig.projectRoot] });
|
|
13
|
+
debug('resolved viteImportPath as %s', viteImportPath);
|
|
14
|
+
return require(viteImportPath);
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
throw new Error(`Could not find "vite" in your project's dependencies. Please install "vite" to fix this error.\n\n${err}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.getVite = getVite;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { StartDevServerOptions };
|
|
5
|
-
export declare function startDevServer(startDevServerArgs: StartDevServerOptions): Promise<Cypress.ResolvedDevServerConfig>;
|
|
6
|
-
export declare type CypressViteDevServerConfig = Omit<InlineConfig, 'base' | 'root'>;
|
|
7
|
-
export declare function devServer(cypressDevServerConfig: Cypress.DevServerConfig, devServerConfig?: CypressViteDevServerConfig): Promise<Cypress.ResolvedDevServerConfig>;
|
|
8
|
-
export declare function defineDevServerConfig(devServerConfig: CypressViteDevServerConfig): CypressViteDevServerConfig;
|
|
1
|
+
import { devServer } from './devServer';
|
|
2
|
+
export { devServer };
|
|
3
|
+
export default devServer;
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
async function startDevServer(startDevServerArgs) {
|
|
8
|
-
const viteDevServer = await (0, startServer_1.start)(startDevServerArgs);
|
|
9
|
-
const app = await viteDevServer.listen();
|
|
10
|
-
const port = app.config.server.port;
|
|
11
|
-
debug('Component testing vite server started on port', port);
|
|
12
|
-
return { port, close: app.httpServer.close };
|
|
13
|
-
}
|
|
14
|
-
exports.startDevServer = startDevServer;
|
|
15
|
-
function devServer(cypressDevServerConfig, devServerConfig) {
|
|
16
|
-
return startDevServer({ options: cypressDevServerConfig, viteConfig: devServerConfig });
|
|
17
|
-
}
|
|
18
|
-
exports.devServer = devServer;
|
|
19
|
-
function defineDevServerConfig(devServerConfig) {
|
|
20
|
-
return devServerConfig;
|
|
21
|
-
}
|
|
22
|
-
exports.defineDevServerConfig = defineDevServerConfig;
|
|
3
|
+
exports.devServer = void 0;
|
|
4
|
+
const devServer_1 = require("./devServer");
|
|
5
|
+
Object.defineProperty(exports, "devServer", { enumerable: true, get: function () { return devServer_1.devServer; } });
|
|
6
|
+
exports.default = devServer_1.devServer;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cypress = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
6
|
+
const pathe_1 = require("pathe");
|
|
7
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
8
|
+
const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
|
|
9
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
10
|
+
const debug = (0, debug_1.default)('cypress:vite-dev-server:plugins:cypress');
|
|
11
|
+
const INIT_FILEPATH = (0, pathe_1.resolve)(__dirname, '../../client/initCypressTests.js');
|
|
12
|
+
const HMR_DEPENDENCY_LOOKUP_MAX_ITERATION = 50;
|
|
13
|
+
function getSpecsPathsSet(specs) {
|
|
14
|
+
return new Set(specs.map((spec) => spec.absolute));
|
|
15
|
+
}
|
|
16
|
+
const Cypress = (options, vite) => {
|
|
17
|
+
let base = '/';
|
|
18
|
+
const projectRoot = options.cypressConfig.projectRoot;
|
|
19
|
+
const supportFilePath = options.cypressConfig.supportFile ? path_1.default.resolve(projectRoot, options.cypressConfig.supportFile) : false;
|
|
20
|
+
const devServerEvents = options.devServerEvents;
|
|
21
|
+
const specs = options.specs;
|
|
22
|
+
const indexHtmlFile = options.cypressConfig.indexHtmlFile;
|
|
23
|
+
let specsPathsSet = getSpecsPathsSet(specs);
|
|
24
|
+
// TODO: use async fs methods here
|
|
25
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
26
|
+
let loader = fs_1.default.readFileSync(INIT_FILEPATH, 'utf8');
|
|
27
|
+
devServerEvents.on('dev-server:specs:changed', (specs) => {
|
|
28
|
+
specsPathsSet = getSpecsPathsSet(specs);
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
name: 'cypress:main',
|
|
32
|
+
enforce: 'pre',
|
|
33
|
+
configResolved(config) {
|
|
34
|
+
base = config.base;
|
|
35
|
+
},
|
|
36
|
+
async transformIndexHtml(html) {
|
|
37
|
+
// it's possibe other plugins have modified the HTML
|
|
38
|
+
// before we get to. For example vitejs/plugin-react will
|
|
39
|
+
// add a preamble. We do our best to look at the HTML we
|
|
40
|
+
// receive and inject it.
|
|
41
|
+
// For now we just grab any `<script>` tags and inject them to <head>.
|
|
42
|
+
// We will add more handling as we learn the use cases.
|
|
43
|
+
const root = (0, node_html_parser_1.parse)(html);
|
|
44
|
+
const scriptTagsToInject = root.childNodes.filter((node) => {
|
|
45
|
+
return node instanceof node_html_parser_1.HTMLElement && node.rawTagName === 'script';
|
|
46
|
+
});
|
|
47
|
+
const indexHtmlPath = (0, pathe_1.resolve)(projectRoot, indexHtmlFile);
|
|
48
|
+
debug('resolved the indexHtmlPath as', indexHtmlPath, 'from', indexHtmlFile);
|
|
49
|
+
let indexHtmlContent = await fs_1.default.promises.readFile(indexHtmlPath, { encoding: 'utf8' });
|
|
50
|
+
// Inject the script tags
|
|
51
|
+
indexHtmlContent = indexHtmlContent.replace('<head>', `<head>
|
|
52
|
+
${scriptTagsToInject.map((script) => script.toString())}
|
|
53
|
+
`);
|
|
54
|
+
// find </body> last index
|
|
55
|
+
const endOfBody = indexHtmlContent.lastIndexOf('</body>');
|
|
56
|
+
// insert the script in the end of the body
|
|
57
|
+
const newHtml = `
|
|
58
|
+
${indexHtmlContent.substring(0, endOfBody)}
|
|
59
|
+
<script>${loader}</script>
|
|
60
|
+
${indexHtmlContent.substring(endOfBody)}
|
|
61
|
+
`;
|
|
62
|
+
return newHtml;
|
|
63
|
+
},
|
|
64
|
+
configureServer: async (server) => {
|
|
65
|
+
server.middlewares.use(`${base}index.html`, async (req, res) => {
|
|
66
|
+
let transformedIndexHtml = await server.transformIndexHtml(base, '');
|
|
67
|
+
const viteImport = `<script type="module" src="${options.cypressConfig.devServerPublicPathRoute}/@vite/client"></script>`;
|
|
68
|
+
// If we're doing cy-in-cy, we need to be able to access the Cypress instance from the parent frame.
|
|
69
|
+
if (process.env.CYPRESS_INTERNAL_VITE_OPEN_MODE_TESTING) {
|
|
70
|
+
transformedIndexHtml = transformedIndexHtml.replace(viteImport, `<script>document.domain = 'localhost';</script>${viteImport}`);
|
|
71
|
+
}
|
|
72
|
+
return res.end(transformedIndexHtml);
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
handleHotUpdate: ({ server, file }) => {
|
|
76
|
+
debug('handleHotUpdate - file', file);
|
|
77
|
+
// If the user provided IndexHtml is changed, do a full-reload
|
|
78
|
+
if (vite.normalizePath(file) === (0, pathe_1.resolve)(projectRoot, indexHtmlFile)) {
|
|
79
|
+
server.ws.send({
|
|
80
|
+
type: 'full-reload',
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
// get the graph node for the file that just got updated
|
|
85
|
+
let moduleImporters = server.moduleGraph.fileToModulesMap.get(file);
|
|
86
|
+
let iterationNumber = 0;
|
|
87
|
+
const exploredFiles = new Set();
|
|
88
|
+
// until we reached a point where the current module is imported by no other
|
|
89
|
+
while (moduleImporters === null || moduleImporters === void 0 ? void 0 : moduleImporters.size) {
|
|
90
|
+
if (iterationNumber > HMR_DEPENDENCY_LOOKUP_MAX_ITERATION) {
|
|
91
|
+
debug(`max hmr iteration reached: ${HMR_DEPENDENCY_LOOKUP_MAX_ITERATION}; Rerun will not happen on this file change.`);
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
// as soon as we find one of the specs, we trigger the re-run of tests
|
|
95
|
+
for (const mod of moduleImporters.values()) {
|
|
96
|
+
debug('handleHotUpdate - mod.file', mod.file);
|
|
97
|
+
if (mod.file === supportFilePath) {
|
|
98
|
+
debug('handleHotUpdate - support compile success');
|
|
99
|
+
devServerEvents.emit('dev-server:compile:success');
|
|
100
|
+
// if we update support we know we have to re-run it all
|
|
101
|
+
// no need to check further
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
if (mod.file && specsPathsSet.has(mod.file)) {
|
|
105
|
+
debug('handleHotUpdate - spec compile success', mod.file);
|
|
106
|
+
devServerEvents.emit('dev-server:compile:success', { specFile: mod.file });
|
|
107
|
+
// if we find one spec, does not mean we are done yet,
|
|
108
|
+
// there could be other spec files to re-run
|
|
109
|
+
// see https://github.com/cypress-io/cypress/issues/17691
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// get all the modules that import the current one
|
|
113
|
+
moduleImporters = getImporters(moduleImporters, exploredFiles);
|
|
114
|
+
iterationNumber += 1;
|
|
115
|
+
}
|
|
116
|
+
return [];
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
exports.Cypress = Cypress;
|
|
121
|
+
/**
|
|
122
|
+
* Gets all the modules that import the set of modules passed in parameters
|
|
123
|
+
* @param modules the set of module whose dependents to return
|
|
124
|
+
* @param alreadyExploredFiles set of files that have already been looked at and should be avoided in case of circular dependency
|
|
125
|
+
* @returns a set of ModuleMode that import directly the current modules
|
|
126
|
+
*/
|
|
127
|
+
function getImporters(modules, alreadyExploredFiles) {
|
|
128
|
+
const allImporters = new Set();
|
|
129
|
+
modules.forEach((m) => {
|
|
130
|
+
if (m.file && !alreadyExploredFiles.has(m.file)) {
|
|
131
|
+
alreadyExploredFiles.add(m.file);
|
|
132
|
+
m.importers.forEach((imp) => {
|
|
133
|
+
allImporters.add(imp);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
return allImporters;
|
|
138
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CypressInspect = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
6
|
+
const debug = (0, debug_1.default)('cypress:vite-dev-server:plugins:inspect');
|
|
7
|
+
const CypressInspect = (config) => {
|
|
8
|
+
var _a;
|
|
9
|
+
if (!process.env.CYPRESS_INTERNAL_VITE_INSPECT) {
|
|
10
|
+
debug('skipping vite inspect because CYPRESS_INTERNAL_VITE_INSPECT is not set');
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
let Inspect;
|
|
14
|
+
try {
|
|
15
|
+
const inspectPluginPath = require.resolve('vite-plugin-inspect', { paths: [config.cypressConfig.projectRoot] });
|
|
16
|
+
const inspectModule = require(inspectPluginPath);
|
|
17
|
+
Inspect = (_a = inspectModule.default) !== null && _a !== void 0 ? _a : inspectModule;
|
|
18
|
+
debug('inspect was found', Inspect);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
debug(`Tried to import the inspect plugin 'vite-plugin-inspect'. It's an optional peerDependency so install it if you'd like.`);
|
|
22
|
+
debug(err);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return Object.assign(Object.assign({}, Inspect()), { name: 'cypress:inspect' });
|
|
26
|
+
};
|
|
27
|
+
exports.CypressInspect = CypressInspect;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createViteDevServerConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
/**
|
|
6
|
+
* The logic inside of this file is heavily reused from
|
|
7
|
+
* Vitest's own config resolution logic.
|
|
8
|
+
* You can find it here https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/create.ts
|
|
9
|
+
*/
|
|
10
|
+
const debug_1 = (0, tslib_1.__importDefault)(require("debug"));
|
|
11
|
+
const local_pkg_1 = require("local-pkg");
|
|
12
|
+
const pathe_1 = require("pathe");
|
|
13
|
+
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const index_1 = require("./plugins/index");
|
|
16
|
+
const debug = (0, debug_1.default)('cypress:vite-dev-server:resolve-config');
|
|
17
|
+
const createViteDevServerConfig = async (config, vite) => {
|
|
18
|
+
const { specs, cypressConfig, viteConfig: viteOverrides } = config;
|
|
19
|
+
const root = cypressConfig.projectRoot;
|
|
20
|
+
const { default: findUp } = await (0, local_pkg_1.importModule)('find-up');
|
|
21
|
+
const configFile = await findUp(constants_1.configFiles, { cwd: root });
|
|
22
|
+
// INFO logging, a lot is logged here.
|
|
23
|
+
// debug('all dev-server options are', options)
|
|
24
|
+
if (configFile) {
|
|
25
|
+
debug('resolved config file at', configFile, 'using root', root);
|
|
26
|
+
}
|
|
27
|
+
else if (viteOverrides) {
|
|
28
|
+
debug(`Couldn't find a Vite config file, however we received a custom viteConfig`, viteOverrides);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (config.onConfigNotFound) {
|
|
32
|
+
config.onConfigNotFound('vite', root, constants_1.configFiles);
|
|
33
|
+
// The config process will be killed from the parent, but we want to early exit so we don't get
|
|
34
|
+
// any additional errors related to not having a config
|
|
35
|
+
process.exit(0);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new Error(`Your component devServer config for vite is missing a required viteConfig property, since we could not automatically detect one.\n Please add one to your ${config.cypressConfig.configFile}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Vite caches its output in the .vite directory in the node_modules where vite lives.
|
|
42
|
+
// So we want to find that node_modules path and ensure it's added to the "allow" list
|
|
43
|
+
const vitePathNodeModules = path_1.default.dirname(path_1.default.dirname(require.resolve(`vite/package.json`, {
|
|
44
|
+
paths: [root],
|
|
45
|
+
})));
|
|
46
|
+
const viteBaseConfig = {
|
|
47
|
+
root,
|
|
48
|
+
base: `${cypressConfig.devServerPublicPathRoute}/`,
|
|
49
|
+
configFile,
|
|
50
|
+
optimizeDeps: {
|
|
51
|
+
esbuildOptions: {
|
|
52
|
+
incremental: true,
|
|
53
|
+
plugins: [
|
|
54
|
+
{
|
|
55
|
+
name: 'cypress-esbuild-plugin',
|
|
56
|
+
setup(build) {
|
|
57
|
+
build.onEnd(function (result) {
|
|
58
|
+
// We don't want to completely fail the build here on errors so we treat the errors as warnings
|
|
59
|
+
// which will handle things more gracefully. Vite will 500 on files that have errors when they
|
|
60
|
+
// are requested later and Cypress will display an error message.
|
|
61
|
+
// See: https://github.com/cypress-io/cypress/pull/21599
|
|
62
|
+
result.warnings = [...result.warnings, ...result.errors];
|
|
63
|
+
result.errors = [];
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
entries: [
|
|
70
|
+
...specs.map((s) => (0, pathe_1.relative)(root, s.relative)),
|
|
71
|
+
...(cypressConfig.supportFile ? [(0, pathe_1.resolve)(root, cypressConfig.supportFile)] : []),
|
|
72
|
+
].filter((v) => v != null),
|
|
73
|
+
},
|
|
74
|
+
server: {
|
|
75
|
+
fs: {
|
|
76
|
+
allow: [
|
|
77
|
+
root,
|
|
78
|
+
vitePathNodeModules,
|
|
79
|
+
cypressConfig.cypressBinaryRoot,
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
plugins: [
|
|
84
|
+
(0, index_1.Cypress)(config, vite),
|
|
85
|
+
(0, index_1.CypressInspect)(config),
|
|
86
|
+
].filter((p) => p != null),
|
|
87
|
+
};
|
|
88
|
+
const finalConfig = vite.mergeConfig(viteBaseConfig, viteOverrides);
|
|
89
|
+
debug('The resolved server config is', JSON.stringify(finalConfig, null, 2));
|
|
90
|
+
return finalConfig;
|
|
91
|
+
};
|
|
92
|
+
exports.createViteDevServerConfig = createViteDevServerConfig;
|
package/package.json
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/vite-dev-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Launches Vite Dev Server for Component Testing",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "tsc",
|
|
8
|
-
"build-prod": "tsc",
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"watch": "tsc -w"
|
|
7
|
+
"build": "tsc || echo 'built, with type errors'",
|
|
8
|
+
"build-prod": "tsc || echo 'built, with type errors'",
|
|
9
|
+
"check-ts": "tsc --noEmit",
|
|
10
|
+
"cypress:run": "yarn cypress:run-cypress-in-cypress node ../../scripts/cypress run --project . --browser chrome",
|
|
11
|
+
"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",
|
|
12
|
+
"cypress:open": "yarn cypress:run-cypress-in-cypress gulp open --project .",
|
|
13
|
+
"watch": "tsc -w",
|
|
14
|
+
"test": "yarn test-unit",
|
|
15
|
+
"test-unit": "mocha -r ts-node/register/transpile-only --config ./test/.mocharc.js"
|
|
14
16
|
},
|
|
15
17
|
"dependencies": {
|
|
16
|
-
"debug": "
|
|
17
|
-
"
|
|
18
|
+
"debug": "4.3.3",
|
|
19
|
+
"find-up": "6.3.0",
|
|
20
|
+
"local-pkg": "0.4.1",
|
|
21
|
+
"node-html-parser": "5.3.3",
|
|
22
|
+
"pathe": "0.2.0"
|
|
18
23
|
},
|
|
19
24
|
"devDependencies": {
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"mocha-multi-reporters": "^1.5.1",
|
|
28
|
-
"react": "17.0.2",
|
|
29
|
-
"vite": "2.2.3",
|
|
30
|
-
"vue": "3.0.11"
|
|
31
|
-
},
|
|
32
|
-
"peerDependencies": {
|
|
33
|
-
"vite": ">= 2.1.3"
|
|
25
|
+
"chai": "^4.3.6",
|
|
26
|
+
"dedent": "^0.7.0",
|
|
27
|
+
"mocha": "^9.2.2",
|
|
28
|
+
"sinon": "^13.0.1",
|
|
29
|
+
"ts-node": "^10.2.1",
|
|
30
|
+
"vite": "3.0.3",
|
|
31
|
+
"vite-plugin-inspect": "0.4.3"
|
|
34
32
|
},
|
|
35
33
|
"files": [
|
|
36
34
|
"dist",
|
package/CHANGELOG.md
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
# [@cypress/vite-dev-server-v2.2.2](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.2.1...@cypress/vite-dev-server-v2.2.2) (2021-12-16)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* check the port is avail on all local hosts ([#19402](https://github.com/cypress-io/cypress/issues/19402)) ([4826175](https://github.com/cypress-io/cypress/commit/4826175040bfc024a36df47dc0c74f2871fa944f))
|
|
7
|
-
|
|
8
|
-
# [@cypress/vite-dev-server-v2.2.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.2.0...@cypress/vite-dev-server-v2.2.1) (2021-11-19)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Bug Fixes
|
|
12
|
-
|
|
13
|
-
* compile npm packages for node 12 ([#18989](https://github.com/cypress-io/cypress/issues/18989)) ([30b3eb2](https://github.com/cypress-io/cypress/commit/30b3eb2376bc1ed69087ba96f60448687e8489e6))
|
|
14
|
-
|
|
15
|
-
# [@cypress/vite-dev-server-v2.2.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.1.1...@cypress/vite-dev-server-v2.2.0) (2021-10-15)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Features
|
|
19
|
-
|
|
20
|
-
* normalized signatures webpack & vite servers ([#18379](https://github.com/cypress-io/cypress/issues/18379)) ([8f5308f](https://github.com/cypress-io/cypress/commit/8f5308f7068b80fb877da539ce34fb67ba497c4f))
|
|
21
|
-
|
|
22
|
-
# [@cypress/vite-dev-server-v2.1.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.1.0...@cypress/vite-dev-server-v2.1.1) (2021-10-04)
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
### Bug Fixes
|
|
26
|
-
|
|
27
|
-
* **vite-dev-server:** remove base and root from inlineVitConfig types ([#17180](https://github.com/cypress-io/cypress/issues/17180)) ([07e7d0e](https://github.com/cypress-io/cypress/commit/07e7d0ed252bf1a2bd3224f617e1fc2e64f19a06))
|
|
28
|
-
* **vite-dev-server:** replace UserConfig with InlineConfig to allow correct `configFile` types ([#18167](https://github.com/cypress-io/cypress/issues/18167)) ([6e0c2c1](https://github.com/cypress-io/cypress/commit/6e0c2c1af81be750a74bad0528d52de45746a453))
|
|
29
|
-
* **vite-dev-server:** windows `supportFile` + preserve optimize entries ([#18286](https://github.com/cypress-io/cypress/issues/18286)) ([ea2f6a4](https://github.com/cypress-io/cypress/commit/ea2f6a45c7057e51b2fc879ff70da75538fa1002))
|
|
30
|
-
|
|
31
|
-
# [@cypress/vite-dev-server-v2.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.8...@cypress/vite-dev-server-v2.1.0) (2021-09-10)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Features
|
|
35
|
-
|
|
36
|
-
* allow usage of @react/plugins with cypress.config.js ([#17738](https://github.com/cypress-io/cypress/issues/17738)) ([da4b1e0](https://github.com/cypress-io/cypress/commit/da4b1e06ce33945aabddda0e6e175dc0e1b488a5))
|
|
37
|
-
|
|
38
|
-
# [@cypress/vite-dev-server-v2.0.8](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.7...@cypress/vite-dev-server-v2.0.8) (2021-08-30)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Bug Fixes
|
|
42
|
-
|
|
43
|
-
* prevent vite from crashing where there are no support files or specs found ([#17624](https://github.com/cypress-io/cypress/issues/17624)) ([ae0ea87](https://github.com/cypress-io/cypress/commit/ae0ea87802168c524ee5cfe04d0aa59a46195a7d)), closes [#17373](https://github.com/cypress-io/cypress/issues/17373)
|
|
44
|
-
* publish the types for vite-dev-server ([#17786](https://github.com/cypress-io/cypress/issues/17786)) ([a94ff69](https://github.com/cypress-io/cypress/commit/a94ff69d09564140ad0cc890771175396eb351cc)), closes [#17648](https://github.com/cypress-io/cypress/issues/17648)
|
|
45
|
-
* repair re-run of vite-dev-server issues ([4139631](https://github.com/cypress-io/cypress/commit/4139631b159bac159bd6d2d4c020b5d8b3aa0fa7))
|
|
46
|
-
|
|
47
|
-
# [@cypress/vite-dev-server-v2.0.7](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.6...@cypress/vite-dev-server-v2.0.7) (2021-08-12)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
### Bug Fixes
|
|
51
|
-
|
|
52
|
-
* **vite-dev-server:** chain update all specs when changing child ([#17693](https://github.com/cypress-io/cypress/issues/17693)) ([66e8896](https://github.com/cypress-io/cypress/commit/66e8896b66207e9ce2d1a5dd9f66f73fe58a1e7e)), closes [#17691](https://github.com/cypress-io/cypress/issues/17691)
|
|
53
|
-
|
|
54
|
-
# [@cypress/vite-dev-server-v2.0.6](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.5...@cypress/vite-dev-server-v2.0.6) (2021-08-10)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
### Bug Fixes
|
|
58
|
-
|
|
59
|
-
* prevent vite from crashing where there are no support files or s… ([#17641](https://github.com/cypress-io/cypress/issues/17641)) ([1d2b053](https://github.com/cypress-io/cypress/commit/1d2b053322eb36935928122e4552563a7f98f35d)), closes [#17624](https://github.com/cypress-io/cypress/issues/17624) [#17373](https://github.com/cypress-io/cypress/issues/17373)
|
|
60
|
-
|
|
61
|
-
# [@cypress/vite-dev-server-v2.0.5](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.4...@cypress/vite-dev-server-v2.0.5) (2021-08-04)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
### Bug Fixes
|
|
65
|
-
|
|
66
|
-
* reload every spec file when support updated ([#17598](https://github.com/cypress-io/cypress/issues/17598)) ([efc38b6](https://github.com/cypress-io/cypress/commit/efc38b67497b48db5b3a636acac3be45dd930593))
|
|
67
|
-
|
|
68
|
-
# [@cypress/vite-dev-server-v2.0.4](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.3...@cypress/vite-dev-server-v2.0.4) (2021-07-31)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### Bug Fixes
|
|
72
|
-
|
|
73
|
-
* **server:** correctly include projectRoot when adding a CI project from GUI ([#17514](https://github.com/cypress-io/cypress/issues/17514)) ([e49b3a4](https://github.com/cypress-io/cypress/commit/e49b3a4b9fc99bb392235b7cad36139faff08eec))
|
|
74
|
-
* only rerun if current spec+deps changed ([#17269](https://github.com/cypress-io/cypress/issues/17269)) ([1433b64](https://github.com/cypress-io/cypress/commit/1433b64d25f186774471593892c1c03aa954c4e3))
|
|
75
|
-
|
|
76
|
-
# [@cypress/vite-dev-server-v2.0.3](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.2...@cypress/vite-dev-server-v2.0.3) (2021-07-27)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
### Bug Fixes
|
|
80
|
-
|
|
81
|
-
* make vite re-run on supportFile change ([#17485](https://github.com/cypress-io/cypress/issues/17485)) ([6cbf4c3](https://github.com/cypress-io/cypress/commit/6cbf4c38296d6287fbcbb0ef5ecd21cf63606153))
|
|
82
|
-
|
|
83
|
-
# [@cypress/vite-dev-server-v2.0.2](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.1...@cypress/vite-dev-server-v2.0.2) (2021-07-15)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
### Bug Fixes
|
|
87
|
-
|
|
88
|
-
* **vite:** autorefresh new spec files ([#17270](https://github.com/cypress-io/cypress/issues/17270)) ([99f9352](https://github.com/cypress-io/cypress/commit/99f93528c87b22656d4d732dfb2ed6843991d861))
|
|
89
|
-
|
|
90
|
-
# [@cypress/vite-dev-server-v2.0.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v2.0.0...@cypress/vite-dev-server-v2.0.1) (2021-06-18)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### Bug Fixes
|
|
94
|
-
|
|
95
|
-
* vite startDevServer needs to return close() ([#16950](https://github.com/cypress-io/cypress/issues/16950)) ([67b2b3b](https://github.com/cypress-io/cypress/commit/67b2b3b9be13437e56384e377c7d32c6e433e064))
|
|
96
|
-
|
|
97
|
-
# [@cypress/vite-dev-server-v2.0.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.7...@cypress/vite-dev-server-v2.0.0) (2021-05-31)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
### Continuous Integration
|
|
101
|
-
|
|
102
|
-
* deliver vue3 on master ([#16728](https://github.com/cypress-io/cypress/issues/16728)) ([0ee001f](https://github.com/cypress-io/cypress/commit/0ee001f6250604711653caf5365d8aca063a9cad)), closes [#15100](https://github.com/cypress-io/cypress/issues/15100)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
### BREAKING CHANGES
|
|
106
|
-
|
|
107
|
-
* no support for vue 2 anymore
|
|
108
|
-
|
|
109
|
-
* build: disable auto deliver of next vue
|
|
110
|
-
|
|
111
|
-
* Revert "feat(vue): vue 3 support in @cypress/vue"
|
|
112
|
-
|
|
113
|
-
This reverts commit 8f55d7baaff1f240677239ae5fdc4180c4a06475.
|
|
114
|
-
|
|
115
|
-
* Revert "build: disable auto deliver of next vue"
|
|
116
|
-
|
|
117
|
-
This reverts commit ed46c9e5c551e57901dbdc75db2e83bf194c4b18.
|
|
118
|
-
|
|
119
|
-
* chore: release @cypress/vue-v1.1.0-alpha.1
|
|
120
|
-
|
|
121
|
-
[skip ci]
|
|
122
|
-
* dropped support for vue 2 in favor of vue 3
|
|
123
|
-
|
|
124
|
-
* test: remove filter tests not relevant in vue 3
|
|
125
|
-
|
|
126
|
-
* build: try publishing as a private new major
|
|
127
|
-
|
|
128
|
-
* chore: release @cypress/vue-v3.0.0-alpha.1
|
|
129
|
-
|
|
130
|
-
[skip ci]
|
|
131
|
-
|
|
132
|
-
* chore: bring back access public
|
|
133
|
-
|
|
134
|
-
* fix: update dependency to webpack dev server
|
|
135
|
-
|
|
136
|
-
* chore: release @cypress/vue-v3.0.0-alpha.2
|
|
137
|
-
|
|
138
|
-
[skip ci]
|
|
139
|
-
|
|
140
|
-
* chore: remove unnecessary dependency
|
|
141
|
-
|
|
142
|
-
* fix: mistreatment of monorepo dependency
|
|
143
|
-
|
|
144
|
-
* chore: release @cypress/vue-v3.0.0-alpha.3
|
|
145
|
-
|
|
146
|
-
[skip ci]
|
|
147
|
-
|
|
148
|
-
* chore: release @cypress/vue-v3.0.0-alpha.4
|
|
149
|
-
|
|
150
|
-
[skip ci]
|
|
151
|
-
|
|
152
|
-
* fix: use __cy_root at the root element
|
|
153
|
-
|
|
154
|
-
* build: avoid using array spread (tslib imports issue)
|
|
155
|
-
|
|
156
|
-
* fix: setup for cypress vue tests
|
|
157
|
-
|
|
158
|
-
* fix: add cleanup event
|
|
159
|
-
|
|
160
|
-
* test: make sure we use the right build of compiler
|
|
161
|
-
|
|
162
|
-
* chore: downgrade VTU to rc-1
|
|
163
|
-
|
|
164
|
-
* chore: release @cypress/vue-v3.0.0
|
|
165
|
-
|
|
166
|
-
[skip ci]
|
|
167
|
-
|
|
168
|
-
* chore: upgrade vue version to 3.0.11
|
|
169
|
-
|
|
170
|
-
* fix: adjust optional peer deps
|
|
171
|
-
|
|
172
|
-
* fix: allow fo any VTU 2 version using ^
|
|
173
|
-
|
|
174
|
-
* test: ignore nuxt example
|
|
175
|
-
|
|
176
|
-
* test: update yarn lock on vue cli
|
|
177
|
-
|
|
178
|
-
* chore: release @cypress/vue-v3.0.1
|
|
179
|
-
|
|
180
|
-
[skip ci]
|
|
181
|
-
|
|
182
|
-
* ci: release vue@next on master
|
|
183
|
-
|
|
184
|
-
* test: fix vue3 examples
|
|
185
|
-
|
|
186
|
-
* ci: open only needed server in circle npm-vue
|
|
187
|
-
|
|
188
|
-
Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
|
|
189
|
-
Co-authored-by: Lachlan Miller <lachlan.miller.1990@outlook.com>
|
|
190
|
-
|
|
191
|
-
# [@cypress/vite-dev-server-v1.2.7](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.6...@cypress/vite-dev-server-v1.2.7) (2021-05-11)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
### Bug Fixes
|
|
195
|
-
|
|
196
|
-
* **vite-dev-server:** only re-run tests when specs deps are updated ([#16215](https://github.com/cypress-io/cypress/issues/16215)) ([31d89a5](https://github.com/cypress-io/cypress/commit/31d89a5e1af9acf173a24c26903a48ff11cde894))
|
|
197
|
-
|
|
198
|
-
# [@cypress/vite-dev-server-v1.2.6](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.5...@cypress/vite-dev-server-v1.2.6) (2021-04-29)
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
### Bug Fixes
|
|
202
|
-
|
|
203
|
-
* **vite-dev-server:** only re-run tests when specs deps are updated ([#16215](https://github.com/cypress-io/cypress/issues/16215)) ([4d23476](https://github.com/cypress-io/cypress/commit/4d23476711d71711590752cada4863a03e1f777f))
|
|
204
|
-
* analyze deps of the specs before starting ([3f52def](https://github.com/cypress-io/cypress/commit/3f52def82e7afe9ee0942e6621924d1d6af5efa8))
|
|
205
|
-
|
|
206
|
-
# [@cypress/vite-dev-server-v1.2.5](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.4...@cypress/vite-dev-server-v1.2.5) (2021-04-27)
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
### Bug Fixes
|
|
210
|
-
|
|
211
|
-
* **vite-dev-server:** fix url to the client on win ([#16220](https://github.com/cypress-io/cypress/issues/16220)) ([c809d19](https://github.com/cypress-io/cypress/commit/c809d19cc139200232a4292529b3bac60d68e995))
|
|
212
|
-
|
|
213
|
-
# [@cypress/vite-dev-server-v1.2.4](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.3...@cypress/vite-dev-server-v1.2.4) (2021-04-26)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
### Bug Fixes
|
|
217
|
-
|
|
218
|
-
* accept absolute paths in vite dev server ([#16148](https://github.com/cypress-io/cypress/issues/16148)) ([684730f](https://github.com/cypress-io/cypress/commit/684730fb68b0394a5c602421b38fbb4d066bf439))
|
|
219
|
-
|
|
220
|
-
# [@cypress/vite-dev-server-v1.2.3](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.2...@cypress/vite-dev-server-v1.2.3) (2021-04-22)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
### Bug Fixes
|
|
224
|
-
|
|
225
|
-
* make vite-dev-server work on windows ([#16103](https://github.com/cypress-io/cypress/issues/16103)) ([a380d02](https://github.com/cypress-io/cypress/commit/a380d020a4211ddbb2f10a61308bd1a6d2e45057))
|
|
226
|
-
|
|
227
|
-
# [@cypress/vite-dev-server-v1.2.2](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.1...@cypress/vite-dev-server-v1.2.2) (2021-04-15)
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
### Bug Fixes
|
|
231
|
-
|
|
232
|
-
* conditionally require vue and update alias if installed ([#16000](https://github.com/cypress-io/cypress/issues/16000)) ([8b97b46](https://github.com/cypress-io/cypress/commit/8b97b4641e7e1b2af8ea38d44273dcc149267e20))
|
|
233
|
-
|
|
234
|
-
# [@cypress/vite-dev-server-v1.2.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.2.0...@cypress/vite-dev-server-v1.2.1) (2021-04-13)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
### Bug Fixes
|
|
238
|
-
|
|
239
|
-
* **vite-dev-server:** Use viteConfig.server.port if defined ([#15893](https://github.com/cypress-io/cypress/issues/15893)) ([d0dcf22](https://github.com/cypress-io/cypress/commit/d0dcf221018cf2c364bc00ff6f750146eb048e7d))
|
|
240
|
-
|
|
241
|
-
# [@cypress/vite-dev-server-v1.2.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.1.0...@cypress/vite-dev-server-v1.2.0) (2021-04-05)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
### Bug Fixes
|
|
245
|
-
|
|
246
|
-
* **vite-dev-server:** import cypress client script asynchronously to avoid flake ([#15778](https://github.com/cypress-io/cypress/issues/15778)) ([88a3830](https://github.com/cypress-io/cypress/commit/88a3830d68ef71290ecad3ab7ba440370f314741))
|
|
247
|
-
* make sure the vite server starts on a new port ([57e2988](https://github.com/cypress-io/cypress/commit/57e29886cb731a90724dc5473cfd97760b370c62))
|
|
248
|
-
* make vite dev server open on a free port ([#15756](https://github.com/cypress-io/cypress/issues/15756)) ([cd66b05](https://github.com/cypress-io/cypress/commit/cd66b05307ff3f40b3a8bf312a409de2e9ab9399))
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
### Features
|
|
252
|
-
|
|
253
|
-
* simplify vite server ([#15416](https://github.com/cypress-io/cypress/issues/15416)) ([adc2fc8](https://github.com/cypress-io/cypress/commit/adc2fc893fbf32f1f6121d18ddb8a8096e5ebf39))
|
|
254
|
-
|
|
255
|
-
# [@cypress/vite-dev-server-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.0.2...@cypress/vite-dev-server-v1.1.0) (2021-03-15)
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
### Bug Fixes
|
|
259
|
-
|
|
260
|
-
* **component-testing:** ensure to call unmount after each test ([#15385](https://github.com/cypress-io/cypress/issues/15385)) ([153fc51](https://github.com/cypress-io/cypress/commit/153fc515a53343758393db795879a64494374551))
|
|
261
|
-
* **component-testing:** make sure vite html is published on npm ([#15379](https://github.com/cypress-io/cypress/issues/15379)) ([325a7ec](https://github.com/cypress-io/cypress/commit/325a7ec56e9dd91e25f39184407751daf3b9a371))
|
|
262
|
-
* **component-testing:** vite server dependency refresh ([#15366](https://github.com/cypress-io/cypress/issues/15366)) ([59dbed9](https://github.com/cypress-io/cypress/commit/59dbed90dcfd6c71d3478cd61d0228cff702087f))
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
### Features
|
|
266
|
-
|
|
267
|
-
* create-cypress-tests installation wizard ([#9563](https://github.com/cypress-io/cypress/issues/9563)) ([c405ee8](https://github.com/cypress-io/cypress/commit/c405ee89ef5321df6151fdeec1e917ac952c0d38)), closes [#9116](https://github.com/cypress-io/cypress/issues/9116)
|
|
268
|
-
* rollup-dev-server for CT ([#15215](https://github.com/cypress-io/cypress/issues/15215)) ([6f02719](https://github.com/cypress-io/cypress/commit/6f02719511459ebe682ec85eecc02f6b418d233a))
|
|
269
|
-
|
|
270
|
-
# [@cypress/vite-dev-server-v1.0.2](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.0.1...@cypress/vite-dev-server-v1.0.2) (2021-03-10)
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
### Bug Fixes
|
|
274
|
-
|
|
275
|
-
* trigger release of the packages ([#15405](https://github.com/cypress-io/cypress/issues/15405)) ([1ce5755](https://github.com/cypress-io/cypress/commit/1ce57554e260850472cf753de68858f47b3f7b3d))
|
|
276
|
-
|
|
277
|
-
# [@cypress/vite-dev-server-v1.0.1](https://github.com/cypress-io/cypress/compare/@cypress/vite-dev-server-v1.0.0...@cypress/vite-dev-server-v1.0.1) (2021-02-17)
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
### Bug Fixes
|
|
281
|
-
|
|
282
|
-
* trigger semantic release ([#15128](https://github.com/cypress-io/cypress/issues/15128)) ([3a6f3b1](https://github.com/cypress-io/cypress/commit/3a6f3b1928277f7086062b1107f424e5a0247e00))
|
|
283
|
-
|
|
284
|
-
# @cypress/vite-dev-server-v1.0.0 (2021-02-16)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
### Features
|
|
288
|
-
|
|
289
|
-
* adding vite-dev-server plugin ([#14839](https://github.com/cypress-io/cypress/issues/14839)) ([0225406](https://github.com/cypress-io/cypress/commit/022540605139545d137125dbb6a85eb995053fcb))
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="cypress" />
|
|
3
|
-
import { Plugin } from 'vite';
|
|
4
|
-
interface Spec {
|
|
5
|
-
absolute: string;
|
|
6
|
-
relative: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const makeCypressPlugin: (projectRoot: string, supportFilePath: string | false, devServerEvents: NodeJS.EventEmitter, specs: Spec[]) => Plugin;
|
|
9
|
-
export {};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.makeCypressPlugin = void 0;
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const fs_1 = require("fs");
|
|
9
|
-
const util_1 = require("util");
|
|
10
|
-
const debug_1 = __importDefault(require("debug"));
|
|
11
|
-
const debug = (0, debug_1.default)('cypress:vite-dev-server:plugin');
|
|
12
|
-
const read = (0, util_1.promisify)(fs_1.readFile);
|
|
13
|
-
const pluginName = 'cypress-transform-html';
|
|
14
|
-
const OSSepRE = new RegExp(`\\${path_1.sep}`, 'g');
|
|
15
|
-
function convertPathToPosix(path) {
|
|
16
|
-
return path_1.sep === '/'
|
|
17
|
-
? path
|
|
18
|
-
: path.replace(OSSepRE, '/');
|
|
19
|
-
}
|
|
20
|
-
const INIT_FILEPATH = (0, path_1.resolve)(__dirname, '../client/initCypressTests.js');
|
|
21
|
-
const HMR_DEPENDENCY_LOOKUP_MAX_ITERATION = 50;
|
|
22
|
-
function getSpecsPathsSet(specs) {
|
|
23
|
-
return new Set(specs.map((spec) => spec.absolute));
|
|
24
|
-
}
|
|
25
|
-
const makeCypressPlugin = (projectRoot, supportFilePath, devServerEvents, specs) => {
|
|
26
|
-
let base = '/';
|
|
27
|
-
let specsPathsSet = getSpecsPathsSet(specs);
|
|
28
|
-
devServerEvents.on('dev-server:specs:changed', (specs) => {
|
|
29
|
-
specsPathsSet = getSpecsPathsSet(specs);
|
|
30
|
-
});
|
|
31
|
-
const posixSupportFilePath = supportFilePath ? convertPathToPosix((0, path_1.resolve)(projectRoot, supportFilePath)) : undefined;
|
|
32
|
-
const normalizedSupportFilePath = posixSupportFilePath ? `${base}@fs/${posixSupportFilePath}` : undefined;
|
|
33
|
-
return {
|
|
34
|
-
name: pluginName,
|
|
35
|
-
enforce: 'pre',
|
|
36
|
-
config(_, env) {
|
|
37
|
-
if (env) {
|
|
38
|
-
return {
|
|
39
|
-
define: {
|
|
40
|
-
'import.meta.env.__cypress_supportPath': JSON.stringify(normalizedSupportFilePath),
|
|
41
|
-
'import.meta.env.__cypress_originAutUrl': JSON.stringify(`__cypress/iframes/${convertPathToPosix(projectRoot)}/`),
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
configResolved(config) {
|
|
47
|
-
base = config.base;
|
|
48
|
-
},
|
|
49
|
-
transformIndexHtml() {
|
|
50
|
-
debug('transformIndexHtml with base', base);
|
|
51
|
-
return [
|
|
52
|
-
// load the script at the end of the body
|
|
53
|
-
// script has to be loaded when the vite client is connected
|
|
54
|
-
{
|
|
55
|
-
tag: 'script',
|
|
56
|
-
injectTo: 'body',
|
|
57
|
-
attrs: { type: 'module' },
|
|
58
|
-
children: `import(${JSON.stringify(`${base}@fs/${INIT_FILEPATH}`)})`,
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
},
|
|
62
|
-
configureServer: async (server) => {
|
|
63
|
-
const indexHtml = await read((0, path_1.resolve)(__dirname, '..', 'index.html'), { encoding: 'utf8' });
|
|
64
|
-
const transformedIndexHtml = await server.transformIndexHtml(base, indexHtml);
|
|
65
|
-
server.middlewares.use(`${base}index.html`, (req, res) => res.end(transformedIndexHtml));
|
|
66
|
-
},
|
|
67
|
-
handleHotUpdate: ({ server, file }) => {
|
|
68
|
-
debug('handleHotUpdate - file', file);
|
|
69
|
-
// get the graph node for the file that just got updated
|
|
70
|
-
let moduleImporters = server.moduleGraph.fileToModulesMap.get(file);
|
|
71
|
-
let iterationNumber = 0;
|
|
72
|
-
const exploredFiles = new Set();
|
|
73
|
-
// until we reached a point where the current module is imported by no other
|
|
74
|
-
while (moduleImporters === null || moduleImporters === void 0 ? void 0 : moduleImporters.size) {
|
|
75
|
-
if (iterationNumber > HMR_DEPENDENCY_LOOKUP_MAX_ITERATION) {
|
|
76
|
-
debug(`max hmr iteration reached: ${HMR_DEPENDENCY_LOOKUP_MAX_ITERATION}; Rerun will not happen on this file change.`);
|
|
77
|
-
return [];
|
|
78
|
-
}
|
|
79
|
-
// as soon as we find one of the specs, we trigger the re-run of tests
|
|
80
|
-
for (const mod of moduleImporters.values()) {
|
|
81
|
-
debug('handleHotUpdate - mod.file', mod.file);
|
|
82
|
-
if (mod.file === supportFilePath) {
|
|
83
|
-
debug('handleHotUpdate - support compile success');
|
|
84
|
-
devServerEvents.emit('dev-server:compile:success');
|
|
85
|
-
// if we update support we know we have to re-run it all
|
|
86
|
-
// no need to ckeck further
|
|
87
|
-
return [];
|
|
88
|
-
}
|
|
89
|
-
if (mod.file && specsPathsSet.has(mod.file)) {
|
|
90
|
-
debug('handleHotUpdate - spec compile success', mod.file);
|
|
91
|
-
devServerEvents.emit('dev-server:compile:success', { specFile: mod.file });
|
|
92
|
-
// if we find one spec, does not mean we are done yet,
|
|
93
|
-
// there could be other spec files to re-run
|
|
94
|
-
// see https://github.com/cypress-io/cypress/issues/17691
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// get all the modules that import the current one
|
|
98
|
-
moduleImporters = getImporters(moduleImporters, exploredFiles);
|
|
99
|
-
iterationNumber += 1;
|
|
100
|
-
}
|
|
101
|
-
return [];
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
exports.makeCypressPlugin = makeCypressPlugin;
|
|
106
|
-
/**
|
|
107
|
-
* Gets all the modules that import the set of modules passed in parameters
|
|
108
|
-
* @param modules the set of module whose dependents to return
|
|
109
|
-
* @param alreadyExploredFiles set of files that have already been looked at and should be avoided in case of circular dependency
|
|
110
|
-
* @returns a set of ModuleMode that import directly the current modules
|
|
111
|
-
*/
|
|
112
|
-
function getImporters(modules, alreadyExploredFiles) {
|
|
113
|
-
const allImporters = new Set();
|
|
114
|
-
modules.forEach((m) => {
|
|
115
|
-
if (m.file && !alreadyExploredFiles.has(m.file)) {
|
|
116
|
-
alreadyExploredFiles.add(m.file);
|
|
117
|
-
m.importers.forEach((imp) => {
|
|
118
|
-
allImporters.add(imp);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
return allImporters;
|
|
123
|
-
}
|
package/dist/startServer.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="cypress" />
|
|
2
|
-
import { ViteDevServer, InlineConfig } from 'vite';
|
|
3
|
-
export interface StartDevServerOptions {
|
|
4
|
-
/**
|
|
5
|
-
* the Cypress dev server configuration object
|
|
6
|
-
*/
|
|
7
|
-
options: Cypress.DevServerConfig;
|
|
8
|
-
/**
|
|
9
|
-
* By default, vite will use your vite.config file to
|
|
10
|
-
* Start the server. If you need additional plugins or
|
|
11
|
-
* to override some options, you can do so using this.
|
|
12
|
-
* @optional
|
|
13
|
-
*/
|
|
14
|
-
viteConfig?: Omit<InlineConfig, 'base' | 'root'>;
|
|
15
|
-
}
|
|
16
|
-
export declare function start(devServerOptions: StartDevServerOptions): Promise<ViteDevServer>;
|
package/dist/startServer.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.start = void 0;
|
|
7
|
-
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
const vite_1 = require("vite");
|
|
9
|
-
const path_1 = require("path");
|
|
10
|
-
const get_port_1 = __importDefault(require("get-port"));
|
|
11
|
-
const makeCypressPlugin_1 = require("./makeCypressPlugin");
|
|
12
|
-
const debug = (0, debug_1.default)('cypress:vite-dev-server:start');
|
|
13
|
-
const resolveServerConfig = async ({ viteConfig, options }) => {
|
|
14
|
-
const { projectRoot, supportFile } = options.config;
|
|
15
|
-
const requiredOptions = {
|
|
16
|
-
base: '/__cypress/src/',
|
|
17
|
-
root: projectRoot,
|
|
18
|
-
};
|
|
19
|
-
const finalConfig = { ...viteConfig, ...requiredOptions };
|
|
20
|
-
finalConfig.plugins = [...(finalConfig.plugins || []), (0, makeCypressPlugin_1.makeCypressPlugin)(projectRoot, supportFile, options.devServerEvents, options.specs)];
|
|
21
|
-
// This alias is necessary to avoid a "prefixIdentifiers" issue from slots mounting
|
|
22
|
-
// only cjs compiler-core accepts using prefixIdentifiers in slots which vue test utils use.
|
|
23
|
-
// Could we resolve this usage in test-utils?
|
|
24
|
-
try {
|
|
25
|
-
finalConfig.resolve = finalConfig.resolve || {};
|
|
26
|
-
finalConfig.resolve.alias = {
|
|
27
|
-
...finalConfig.resolve.alias,
|
|
28
|
-
'@vue/compiler-core': (0, path_1.resolve)((0, path_1.dirname)(require.resolve('@vue/compiler-core')), 'dist', 'compiler-core.cjs.js'),
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
// Vue 3 is not installed
|
|
33
|
-
}
|
|
34
|
-
finalConfig.server = finalConfig.server || {};
|
|
35
|
-
finalConfig.server.port = await (0, get_port_1.default)({ port: finalConfig.server.port || 3000 }),
|
|
36
|
-
// Ask vite to pre-optimize all dependencies of the specs
|
|
37
|
-
finalConfig.optimizeDeps = finalConfig.optimizeDeps || {};
|
|
38
|
-
// pre-optimize all the specs
|
|
39
|
-
if ((options.specs && options.specs.length)) {
|
|
40
|
-
// fix: we must preserve entries configured on target project
|
|
41
|
-
const existingOptimizeDepsEntries = finalConfig.optimizeDeps.entries;
|
|
42
|
-
if (existingOptimizeDepsEntries) {
|
|
43
|
-
finalConfig.optimizeDeps.entries = [...existingOptimizeDepsEntries, ...options.specs.map((spec) => spec.relative)];
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
finalConfig.optimizeDeps.entries = [...options.specs.map((spec) => spec.relative)];
|
|
47
|
-
}
|
|
48
|
-
// only optimize a supportFile is it is not false or undefined
|
|
49
|
-
if (supportFile) {
|
|
50
|
-
// fix: on windows we need to replace backslashes with slashes
|
|
51
|
-
finalConfig.optimizeDeps.entries.push(supportFile.replace(/\\/g, '/'));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
debug(`the resolved server config is ${JSON.stringify(finalConfig, null, 2)}`);
|
|
55
|
-
return finalConfig;
|
|
56
|
-
};
|
|
57
|
-
async function start(devServerOptions) {
|
|
58
|
-
if (!devServerOptions.viteConfig) {
|
|
59
|
-
debug('User did not pass in any Vite dev server configuration');
|
|
60
|
-
devServerOptions.viteConfig = {};
|
|
61
|
-
}
|
|
62
|
-
debug('starting vite dev server');
|
|
63
|
-
const resolvedConfig = await resolveServerConfig(devServerOptions);
|
|
64
|
-
return (0, vite_1.createServer)(resolvedConfig);
|
|
65
|
-
}
|
|
66
|
-
exports.start = start;
|
package/index.html
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
-
<title>AUT Frame</title>
|
|
8
|
-
</head>
|
|
9
|
-
<body>
|
|
10
|
-
<div id="__cy_root"></div>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|