testSequencer.js 565 字节
Newer Older
A
Anne_LXM 已提交
1
const Sequencer = require("@jest/test-sequencer").default;
Anne_LXM's avatar
Anne_LXM 已提交
2
const sortTestFilenames = ["add.test.js","list.test.js","detail.test.js","edit.test.js"];
A
Anne_LXM 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16
class CustomSequencer extends Sequencer {
  sort(tests) {
    // 测试例排序
    const copyTests = Array.from(tests);
    const sortTests = sortTestFilenames
      .map((filename) => {
        return copyTests.find((test) => test.path.endsWith(filename));
      })
      .filter(Boolean);
    console.log(sortTests);
    return [...new Set([...sortTests, ...copyTests])];
  }
}
module.exports = CustomSequencer;