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

server side tests #274

Closed
fibo opened this issue Jul 5, 2016 · 5 comments
Closed

server side tests #274

fibo opened this issue Jul 5, 2016 · 5 comments

Comments

@fibo
Copy link

fibo commented Jul 5, 2016

Intro

I am opening this issue to keep track of this pull request ForbesLindesay/matches-selector#1 which should solve it.

Minimal example

I am testing a Root React component which contains a component that do a new Clipbloard.

The test is something like

import React from 'react'
import reactDom from 'react-dom/server'
import dom from 'cheerio'
import Root from 'components/Root'

const render = reactDom.renderToStaticMarkup

import test from 'tape'

const noop = () => {}

const props = {
  goal: { list: [] },
  isEditing: {
    goal: false,
    postback: false
  },
  onChange: {
    goal: {}
  },
  onClick: {
    goal: {}
  },
  onClickGoal: noop,
  onClickNew: noop,
  onMount: noop
}

test('Root component', (t) => {
  const el = (
    <Root
      {...props}
    />
  )

  const $ = dom.load(render(el))
  const $h1 = $('h1')

  t.equal($h1.html(), 'My app')

  t.end()
})

Expected behaviour

Run tests server side with no error.

Actual behaviour

When I run tests server side, since Clipboard uses ForbesLindesay/matches-selector, I get this error

var proto = Element.prototype;
            ^

ReferenceError: Element is not defined

Browsers affected

None

@antonbarada
Copy link

  • with angular universal

@zenorocha
Copy link
Owner

I think this is finally fixed in v1.5.14, could you please test it @fibo and @thebarada?

@fibo
Copy link
Author

fibo commented Oct 23, 2016

ok, thanks!

I opened an issue on a component using Clipboard.js (maybe you do not see it cause it is private), so it is in my todo list.

@zenorocha
Copy link
Owner

Awesome! I basically got rid of the dependency that caused that problem and rewrite that piece of code. Now I have control to change anything if needed.

@fibo
Copy link
Author

fibo commented Oct 24, 2016

here it is the issue on the private repo

screen shot 2016-10-24 at 10 42 55

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

3 participants