Skip to main content


¥Writing system tests

系统测试验证 Stylelint 是否按预期工作。它们是继单元测试和集成测试之后防止回归的另一道防线。

¥System tests verify that Stylelint works as expected. They are another line of defense against regressions, after the unit tests and integration tests.


¥Each of these system tests asserts that we end up with some expected output, given a configuration and a stylesheet.


¥These tests should not be comprehensive and systematic (the unit tests should). They should reproduce real use-cases and verify that those use-cases work as expected.

Jest 快照

¥Jest snapshots

测试使用 Jest 快照,因此我们可以轻松地:

¥The tests use Jest snapshots, so we can easily:

  • 针对潜在的大对象和字符串进行断言

    ¥assert against potentially large objects and strings

  • 根据需要更新期望。

    ¥update expectations as needed.


¥The pattern


¥To add a system test, you should:

  • 将测试用例文件夹添加到 system-tests/,增加现有测试用例的数量

    ¥add a test-case folder to system-tests/ incrementing the number from existing test cases

  • 添加配置文件和样式表

    ¥add a configuration file and a stylesheet

  • 按照现有测试建立的格式添加 fs.test.jsno-fs.test.js,并使用 systemTestUtils

    ¥add a fs.test.js and no-fs.test.js following the format established by existing tests, and using the systemTestUtils

  • 拍摄 output 的快照

    ¥take a snapshot of output