Giter Site home page Giter Site logo

Comments (3)

zwass avatar zwass commented on May 28, 2024

@noahtalerman I am not totally clear on how importing assets in JS works. Would this approach (1) actually check that the contents of the img tag match the source file?

from fleet.

noahtalerman avatar noahtalerman commented on May 28, 2024

Would this approach (1) actually check that the contents of the img tag match the source file?

I believe yes.

import React from 'react'; 
import {shallow} from 'enzyme';

import Logo from "./../Logo"; 
import logoImage from "./../../../assets/images/logo.png;

describe("<Logo />", () => {
    it("renders an image", () => {
        const logo = shallow(<Logo />);

        expect(logo.find("img").prop("src")).toEqual(logoImage);

     });
 });

Approach (1) is inspired by the example code above. In the example, one image asset is imported and used to check one img tag. Approach (1) builds on this idea by creating a grouping of all possible (expected) assets and then checking that the src of each img tag is included in the grouping.

I'm not yet clear on the details of Jest's .toHaveProperty().

from fleet.

noahtalerman avatar noahtalerman commented on May 28, 2024

From Slack:

After more thinking, I’m flipping on my decision to write unit tests to check that all img tags have a source that doesn’t 404.
I think if I wrote the tests now, they would require a decent amount of upkeep when we make further changes to icons in the front end code. To me, it now makes more sense to include tests for broken images when we tackle end to end testing.
For now, instead of writing the unit tests, I’m going to spend 30-60 min QAing the front end to make sure there are no broken images or additional bugs. I’ll be performing a similar QA pass before each release.

from fleet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.