Skip to content

AAA (Arrange-Act-Assert) style #1

@lunmanlee

Description

@lunmanlee

I was learning about writing tests for react components, mainly what it looks like to TDD(Test Driven Development) react components and I came across AAA.

It's another structure for writing good tests:

Arrange - set up everything the test needs; initialise functions, render components, pass in props, test data, contexts, mock ext. dependencies etc.

Act - perform the behaviour we want to test, like firing a user effect, calling a function, awaiting async effects and so on

Assert - check that the observed outcome matches the expectations

In the Rails world where we use Rspec, AAA draws parallel with describe -> context -> it

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions