question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Functional components

See original GitHub issue

Is it possible to use avoriaz to test functional components? When I quickly tried it out earlier it gave me an error that the context parameter for the component’s render function was undefined.

If I change the mounting to something like this

new Vue({
  components: {
    Test: component
  },
  render (h) {
    return h('test', options)
  }
})

then I don’t get the error message, but everything in context.props is undefined, like this.

{
  prop1: undefined,
  prop2: undefined
}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nekosaurcommented, Jun 13, 2017

Here’s a very simple functional component that I was testing with.

{
  functional: true,
  render: (h, { data, children }) => {
    return h('div', data, children)
  }
}

I was mounting it like any other component.

const wrapper = mount(Component)

It doesn’t matter if I pass an options object with propsData or not, I always get this error.

TypeError: Cannot convert undefined or null to object
      at mount (node_modules/avoriaz/dist/mount.js:53:10)
      at Object.it (test/unit/specs/Avatar.spec.js:23:40)
      at Promise.resolve.then.el (node_modules/p-map/index.js:42:16)
      at process._tickCallback (internal/process/next_tick.js:109:7)
0reactions
nekosaurcommented, Jun 25, 2017

Thank you! I’ve tested it and it works fine so far 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Components and Props - React
Components let you split the UI into independent, reusable pieces, and think about each piece in isolation. This page provides an introduction to...
Read more >
Functional Components vs Class Components in React
Functional components are basic JavaScript functions. · Sometimes referred to as “dumb” or “stateless” components as they simply accept data and ...
Read more >
ReactJS Functional Components - GeeksforGeeks
Functional components are some of the more common components that will come across while working in React. These are simply JavaScript ...
Read more >
React Function Components
React Function Components -- also known as React Functional Components -- are the status quo of writing modern React applications.
Read more >
Function Components - React TypeScript Cheatsheets
Function Components. These can be written as normal functions that take a props argument and return a JSX element. // Declaring type of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found