Skip to content

snapshot tests failing with Cannot read property 'split' of null #1381

@pho3nixf1re

Description

@pho3nixf1re

Description

When snapshots do not match a type error is thrown instead of the diff. TypeError: Cannot read property 'split' of null.

Test Source

import React from 'react';
import test from 'ava';
import { render } from 'enzyme';

const TestMe = ({ me }) => (
  <div>
    <p>{me}</p>
  </div>
);

test('renders the component', t => {
  const wrapper = render(<TestMe me='change me' />);
  t.snapshot(wrapper.html());
});

Error Message & Stack Trace

Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
  ✖ renders the component Error thrown in test

  1 test failed [11:04:02]

  renders the component
  /path/to/example.test.js:13

   12:   const wrapper = render(<TestMe me='change us' />);
   13:   t.snapshot(wrapper.html());
   14: });

  Error thrown in test

  Error:

    [TypeError: Cannot read property 'split' of null]

Config

Copy the relevant section from package.json:

{
  "ava": {
    "require": [
      "babel-register",
      "./test-environment.js"
    ],
    "babel": "inherit",
    "files": [
      "**/*.test.js",
      "!node_modules"
    ]
  }
}

Command-Line Arguments

Copy your npm build scripts or the ava command used:

ava --verbose path/to/example.test.js

Relevant Links

https://gist.github.com/pho3nixf1re/4c23d77709ce4ef044ebae7c937940ec

Environment

Node.js v7.10.0
darwin 16.5.0
AVA 0.19.1
npm 4.2.0
yarn v0.23.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcurrent functionality does not work as desired

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions