Skip to content

UI Tests via CSS #86

Open
Open
@aleemb

Description

@aleemb

I am not sure if this is common practise or not but some of our developers ended up creating .grid__item without a .grid or incorrect nesting. I came up with an idea for a system for catching these through a test stylesheet along the lines of:

/* grid__item should always be within a grid */
.grid__item {
    outline: 5px solid red;
}
.grid > .grid__item {
    outline: none;
}

/* grid should only have grid__item as children */
.grid > :not(.grid__item) {
    outline: 5px solid red;
}

I am pretty sure this idea can be extended to other rules to allow developers to visually validate markup. It helped me catch a bunch of errors, especially when markup is being dynamically generated, nested or refactored.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions