Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Reorganize tests #1542

Open
Open
@smashwilson

Description

@smashwilson

Our test suite contains a mish-mash of tests that bridge various scopes; some use a real DOM and test full component subtrees (test/controllers/status-bar-tile-controller.test.js), while others exercise a single component. Some use imperative-style component methods to drive the action while others stick to simulated events. I think we even still have some raw DOM method manipulation in there from the etch days.

While I'm less interested in being pedantic about what constitutes different categories of tests, it would be nice to have some consistency. What I most value in a test suite is the amount of signal that I get from a failing test - when I see an ❌ commit status, I'd like to be able to quickly identify which bits of the codebase are likely to contain the bug.

What I'd like to do is have two distinct categories of tests:

  • "Unit" tests that exercise a single model or React component.
    • Use Enzyme's shallow() renderer whenever possible. Notable exception: React components that use render props cannot be tested with shallow().
    • Drive action mostly through prop changes, simulated events, and the component lifecycle.
    • Judiciously mock filesystem, network, and other OS operations. Mock the Atom API when necessary.
    • Assert against component state, markup produced by that component directly, or against props passed to immediate children.
  • "Integration" tests that exercise a workflow or user story holistically across the codebase.
    • Instantiate a full GithubPackage. Use an isolated DOM tree and Atom environment for each test.
    • Provide Enzyme access with a mount() call on the package's root component.
    • Use real git repositories, filesystem events, and local network activity. Mock external network activity.
    • Drive action through simulated events, Atom commands, and external manipulation (git operations).
    • Assert against markup anywhere in the hierarchy (use single CSS classes for targeting as much as possible to limit our fragility) or against modifications in external state.

/cc @annthurium @sguthals for feedback
/cc @meaghanlewis for awareness and any (totally non-urgent, highly asynchronous) comments

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions