bahmutov / cypress-svelte-unit-test

Unit testing Svelte components in Cypress E2E test runner
162 stars 21 forks source link

HelloWorld is not defined #219

Closed edsonharantes closed 3 years ago

edsonharantes commented 3 years ago

Hello, I'm new to cypress and I can't make the component test work. I'm using svelte only (no sapper), I have a simple svelte component named HelloWorld, he has no props, when I open cypress and tried to run the spec, a error message appears.

ReferenceError: The following error originated from your test code, not from Cypress.

HelloWorld is not defined

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.

Check your console for the stack trace or click this message to see where it originated from. at eval (http://localhost:57999/__cypress/tests?p=cypress\integration\item.spec.js:1:4541) at eval () From previous event: at Object.runScripts (http://localhost:57999/__cypress/runner/cypress_runner.js:176896:96) at $Cypress.onSpecWindow (http://localhost:57999/__cypress/runner/cypress_runner.js:166807:18)

bahmutov commented 3 years ago

Hi, there is not enough information to debug this failing test. Can you paste the spec file?

edsonharantes commented 3 years ago

Component:

Hello World

Spec:

/// import HelloWorld from './HelloWorld.svelte' import { mount } from 'cypress-svelte-unit-test'

/ eslint-env mocha / describe('Hello world', () => { it('shows hello', () => { mount(HelloWorld); }) })

cypress plugin index.js

module.exports = (on, config) => { // https://github.com/bahmutov/cy-rollup const filePreprocessor = require('@bahmutov/cy-rollup') on('file:preprocessor', filePreprocessor())

return config }

cypres.json:

{ "video": false, "viewportHeight": 300, "viewportWidth": 300, "testFiles": "*/spec.js", "experimentalComponentTesting": true, "experimentalFetchPolyfill": true, "componentFolder": "src", "nodeVersion": "system" }

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 3.3.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: