Questions tagged [enzyme]

Unit test library for React. It is developed by Airbnb. It can be used with other JavaScript testing frameworks like Mocha, Jest, Karma, etc.

Enzyme is a JavaScript testing utility for React that makes it easier to assert, manipulate, and traverse your React components' output.

Enzyme's API is meant to be intuitive and flexible by mimicking jQuery's API for DOM manipulation and traversal.

Enzyme is unopinionated regarding which test runner or assertion library you use and should be compatible with all major test runners and assertion libraries out there. The documentation and examples for Enzyme use Mocha and Chai, but you should be able to extrapolate to your framework of choice.

4320 questions
2
votes
1 answer

How do I run my mocha.js tests in visual studio online build process

I have a react web application, that uses webpack. Due to the issue with Left-pad I am including my node_modules folder in source control. I have mocha and enzyme set up to unit test my react modules and my packages.json has the following test…
David Kethel
  • 2,440
  • 9
  • 29
  • 49
2
votes
1 answer

Testing JSX inside .map function using Enzyme

So say i have this table: {cats.map(cat => { return ( …
IAmAkittycatAMA
  • 225
  • 4
  • 12
2
votes
2 answers

How to find element with Enzyme unit testing?

I have a unit test that uses that contains function which works. Is it possible to select an node from a collection and then take the text property? I tried this: it('should be equaling name property', () => { const props = { …
bier hier
  • 20,970
  • 42
  • 97
  • 166
2
votes
1 answer

Why do enzyme not find 'tr' in a table?

I'm writting some test using enzyme but I have some weird behavior. Here is my test : import React from 'react' import { TypeTable } from 'routes/Type/components/TypeTable' import { shallow } from 'enzyme' import { Table } from…
ThomasThiebaud
  • 11,331
  • 6
  • 54
  • 77
2
votes
0 answers

How to mock foundation in mocha uni test

I am using mocha for unit testing.I have used foundation library and have initialized it in componentDidMount() and componentDidUpdate() as below componentDidMount(){ $("#element").foundation(); } In testutils setup file i have initialized…
Sweety
  • 33
  • 1
  • 5
2
votes
1 answer

Shallow rendering using enzyme simple test not working

I am very new to the enzyme/shallow render testing. I probably don't fully understand it yet. Using this simplified component: export const PlacementOption = (props) =>
const UpdatingSelectField = (props) =>
export class…
Kocur4d
  • 6,701
  • 8
  • 35
  • 53
2
votes
1 answer

Unit testing using Jest for React/Redux Component

I am testing my connected component using Jest. This is how the component looks: import React, {Component, PropTypes} from 'react'; import { connect } from 'react-redux'; class MyComponent extends Component { constructor(){ super(); …
Varsha
  • 53
  • 6
2
votes
1 answer

Why enzyme `mount` can't find text in inner components?

I defined some react components: src/hello.jsx import React from 'react'; import Box from './box.jsx'; class Hello extends React.Component { render() { const {fruit} = this.props; return

Hello, I like:

{ …
Freewind
  • 193,756
  • 157
  • 432
  • 708
2
votes
1 answer

Why does React add '.$' to the start of a key

I have react component that renders something like:
something
when I query the keys of each node (using enzyme if that matters), my keys are printed as .$bowie Is the .$ something I can rely on? What does it…
brendangibson
  • 2,377
  • 2
  • 21
  • 36
2
votes
1 answer

Enzyme and Mocha gives me error for a Istanbul coverage test, why?

I have a ReactJs project and I'm using unit tests with Enzyme and Mocha. I setup my package.json to execute this command: ./node_modules/.bin/mocha --compilers js:babel-register --require 'app/tests/support/setup.mocha.js' --recursive…
axel
  • 3,778
  • 4
  • 45
  • 72
2
votes
1 answer

Simulate a click on span tag in enzyme

I have a span tag in my component and I need to click it using enzyme Reserve this chat Here is my…
Thomas John
  • 2,138
  • 2
  • 22
  • 38
2
votes
1 answer

how to test an attribute's attribute of an object type prop in enzyme?

This is what my jsx file contains, {' '+this.props.file.attached.name} How can I write test for this name ?
Thomas John
  • 2,138
  • 2
  • 22
  • 38
2
votes
3 answers

React + Enzyme error: Invariant Violation: dangerouslyRenderMarkup(...): Cannot render markup in a worker thread

I am testing a react component using Enzyme and I'm getting the following error: Invariant Violation: dangerouslyRenderMarkup(...): Cannot render markup in a worker thread. Make sure window and document are available globally before requiring React…
Yaniv Efraim
  • 6,633
  • 7
  • 53
  • 96
2
votes
1 answer

TypeError jQuery timepicker is not a function on test

I'm building a test using Mocha and Chai for my ReactJS components. Basically I have this structure for my components: ScheduleApp ScheduleForm Under my ScheduleForm I'm using this jQuery plugin bootstrap-timepicker. I'm using another plugin…
JohnnyQ
  • 4,839
  • 6
  • 47
  • 65
2
votes
0 answers

Can't find nodes with enzyme and css-modules when using karma-webpack

I've been using css-modules with mocha, enzyme and css-modules-require-hook without any problems. Foo.js import React from 'react'; import styles from './Foo.css'; const Foo = () =>
Foo component
; export default…
qmmr
  • 502
  • 1
  • 5
  • 17
1 2 3
99
100
cat name
{ cat.name }