Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jest not creating snapshot

i have created a jest test file below.But the snapshot for this file is not created. What is the issue in my code?

import React from 'react';
import Carousel from './component';
import renderer from 'react-test-renderer';

test('Carousel Component Test Suite', () => {

const component = renderer.create(
    <Carousel
       />
);

let tree = component.toJSON();
expect(tree).toMatchSnapshot();

});
like image 440
sheeba Avatar asked Aug 18 '17 10:08

sheeba


2 Answers

You have to update the test case. Fire the command below in command prompt/terminal etc.

npm test -u YourTest.spec.js

Do this in project root directory.

like image 133
Hemant Sankhla Avatar answered Oct 09 '22 00:10

Hemant Sankhla


I ran it locally (swapping in a simple component) and it generated a .snap file.

As far as I can see everything looks fine but it may be a problem with a specific version of a dependency you're using (but without seeing your package.json it's impossible to say).

like image 37
tschumann Avatar answered Oct 09 '22 01:10

tschumann