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

Can't test React components with Storybook #1147

Closed
mkubrycz opened this issue Jan 18, 2017 · 10 comments
Closed

Can't test React components with Storybook #1147

mkubrycz opened this issue Jan 18, 2017 · 10 comments
Assignees
Labels
!IMPORTANT! STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Milestone

Comments

@mkubrycz
Copy link

Are you requesting a feature or reporting a bug?

bug

What is the current behavior?

In our project we use React Storybook and we can't run tests for it with testcafe. When trying to run tests against storybook's server we keep getting this error:

 Storybook
 ✖ Component

   1) Error on page "http://localhost:6006/":

      Uncaught TypeError: se[e.type] is not a function

      Browser: Chrome 55.0.2883 / Mac OS X 10.12.2



 1/1 failed (1s)

screen shot 2017-01-18 at 12 28 29

What is the expected behavior?

for tests to run and pass

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL: local storybook server

Test code

import { Selector } from 'testcafe';

fixture `Storybook`
    .page `http://localhost:6006/`;

test('Component', async t => {
    await t
        .click(Selector('#component'))
       // it doesn't matter what are test instructions
});

Specify your

  • operating system: Mac OS X 10.12.2
  • testcafe version: 0.11.1
  • node.js version: 6.9.1
@helen-dikareva helen-dikareva added !IMPORTANT! TYPE: bug The described behavior is considered as wrong (bug). labels Jan 18, 2017
@helen-dikareva helen-dikareva added this to the Sprint #3 milestone Jan 18, 2017
@churkin
Copy link
Contributor

churkin commented Jan 19, 2017

@mkubrycz I'm researching it now

@churkin
Copy link
Contributor

churkin commented Jan 19, 2017

Hi @mkubrycz,
I've deployed storybook demo app - https://github.com/kadira-samples/react-storybook-demo. And get a lot of js errors without testcafe:

storybook

Please, try to skip js errors.. Let me know if it helps.

@mkubrycz
Copy link
Author

Hi @churkin,

so I've tried and skipping js errors results with error:

1) The specified selector does not match any element in the DOM tree.

my browser displays just blank page although url is correct.

@churkin
Copy link
Contributor

churkin commented Jan 20, 2017

@mkubrycz Unfortunately I need example for debugging. Could you share problem link?

@mkubrycz
Copy link
Author

mkubrycz commented Jan 23, 2017

@churkin
For example you can try setting simple react app with create-react-app and then follow instructions on storybook page.
I get the same results here without any js errors

testcode:

import { Selector } from 'testcafe';

const helloButton = Selector("button").withText("Hello Button");

fixture `Storybook`
    .page `http://localhost:9001/`;

test('Storybook example', async t => {
    await t
        .switchToIframe("#storybook-preview-iframe")
        .click(helloButton);
});

I've created github repo with this problem, just:

$ npm install
$ npm run storybook

test is under test/test-example.js

@miherlosev
Copy link
Collaborator

I ran test-example.js from your repo and got an error:
Report

It looks like you don't add a file with page model definitions.

Please, provide this file.

@mkubrycz
Copy link
Author

@miherlosev
Sorry I was copying quickly from another example I was trying to run. It was supposed to be:

import { Selector } from 'testcafe';

const helloButton = Selector("button").withText("Hello Button");

fixture `Storybook`
    .page `http://localhost:9001/`;

test('Storybook example', async t => {
    await t
        .switchToIframe("#storybook-preview-iframe")
        .click(helloButton);
});

from the start.
I've fixed this in my repo. Still doesn't work, when I run normally I get Uncaught TypeError: se[e.type] is not a function and when I'm ignoring js errors The specified selector does not match any element in the DOM tree. and there's nothing displayed in the browser window besides Waiting for an element to appear.

@miherlosev
Copy link
Collaborator

miherlosev commented Jan 24, 2017

Cannot reproduce.

screen shot 2017-01-24 at 4 06 38 pm

Try to update to the latest testcafe version - 0.12.1 and reproduce the bug with this version.

@mkubrycz
Copy link
Author

Thank you @miherlosev and @churkin !

new version indeed fixed my problem.

@lock
Copy link

lock bot commented Mar 29, 2019

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.

@lock lock bot added the STATE: Auto-locked An issue has been automatically locked by the Lock bot. label Mar 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
!IMPORTANT! STATE: Auto-locked An issue has been automatically locked by the Lock bot. TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

No branches or pull requests

5 participants