Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please place the spec in component folder #300

Open
pleymor opened this issue May 8, 2022 · 0 comments
Open

Please place the spec in component folder #300

pleymor opened this issue May 8, 2022 · 0 comments

Comments

@pleymor
Copy link

pleymor commented May 8, 2022

Hi! I follow the guidelines but am unable to run cypress unit tests on vite + svelte.

I get the error:

In order to use mount or unmount functions please place the spec in component folder

I simply created a new project with:

npm create vite@latest

Then installed cypress to finally get:

package.json

  "devDependencies": {
    "@cypress/vite-dev-server": "^2.2.2",
    "@tsconfig/svelte": "^2.0.1",
    "cypress": "^9.6.0",
    "cypress-svelte-unit-test": "^3.3.4",
    "svelte": "^3.44.0",
    "svelte-check": "^2.2.7",
    "svelte-preprocess": "^4.9.8",
    "tslib": "^2.3.1",
    "typescript": "^4.5.4",
    "vite": "^2.9.7"
  },
  "dependencies": {
    "svelte-navigator": "^3.1.5"
  }

cypress/plugins/index.ts

const path = require('path')
import { startDevServer } from '@cypress/vite-dev-server';

/**
 * @type {Cypress.PluginConfig}
 */
export default (on, config) => {
    on('dev-server:start', (options) => {
        return startDevServer({
            options,
            viteConfig: {
                configFile: path.resolve(__dirname, '..', '..', 'vite.config.js'),
            },
        })
    })
}

cypress.json

{
  "projectId": "q8zv52",
  "video": false,
  "testFiles": "**/*.cy-spec.ts",
  "componentFolder": "src"
}

vite.config.js

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [svelte()]
})

src/App.cy-spec.ts

import { defineConfig } from 'vite'
import { svelte } from '@sveltejs/vite-plugin-svelte'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [svelte()]
})

Using node 16 on ubuntu 22.04.

Actual behavior

npm run cy:run-ct
  1. App
    renders App with correct heading:
    Error: In order to use mount or unmount functions please place the spec in component folder

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant