https://cypress.io logo
#vue
Title
# vue
r

rich-lamp-44536

01/18/2022, 8:57 PM
Quasar Vite Testing (
dev-server start
)
Hey folks, I need some help with my quasar vite vue 3 cypress setup
My `cypress/plugins/index.ts`:
Copy code
ts
import { startDevServer } from '@cypress/vite-dev-server';
import path from 'node:path';

/**
 * @param on is used to hook into various events Cypress emits
 * @param config is the resolved Cypress config
 */
export default (
  on: Cypress.PluginEvents,
  config: Cypress.PluginConfigOptions,
): void | Cypress.ConfigOptions | Promise<Cypress.ConfigOptions> => {
  on('dev-server:start', async (options) => {
    return startDevServer({
      options,
      viteConfig: {
        configFile: path.resolve(__dirname, '..', '..', 'vite.config.ts'),
      },
    });
  });

  return config;
};
When I log something in the function itself it shows up in console, so the file is definitely taken. BUT when I try to log something in the
dev-server:start
on
-callback, it does not show up 🙁 The server is not starting a vite instance.
My `vite.config.ts`:
Copy code
ts
import content from '@originjs/vite-plugin-content';
import { quasar, transformAssetUrls } from '@quasar/vite-plugin';
import vue from '@vitejs/plugin-vue';
import { resolve } from 'node:path';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue({
      template: { transformAssetUrls },
    }),
    quasar({
      autoImportComponentCase: 'pascal',
      sassVariables: 'src/quasar-variables.scss',
    }),
    content(),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, './src'),
    },
  },
  css: {
    postcss: {
      plugins: [
        {
          postcssPlugin: 'internal:charset-removal',
          AtRule: {
            charset(atRule) {
              if (atRule.name === 'charset') {
                atRule.remove();
              }
            },
          },
        },
      ],
    },
  },
  server: {
    port: 5173,
  },
  preview: {
    port: 4173,
  },
});
But theoretically this config should be irrelevant, cause as I say, the callback doesn't get called at all!
Copy code
"@cypress/vite-dev-server": "~2.2.2"
"@cypress/vue": "~3.0.0-beta.4"
"cypress": "~9.2.1"
(please @-mention me when writing me, so I get notified 🙂 )
keep-alive-ping
Final solution:
Copy code
js
    "cypress": "cypress",
    "cypress:open": "run-p --race start 'cypress open'",
    "cypress:open:ct": "cypress open-ct",
    "cypress:run": "run-p --race start 'cypress run'",
    "cypress:run:ct": "cypress run-ct",
11 Views