testSequencer.js 683 字节
Newer Older
study夏羽's avatar
study夏羽 已提交
1
const Sequencer = require("@jest/test-sequencer").default;
Anne_LXM's avatar
Anne_LXM 已提交
2
const sortTestFilenames = ["grid.test.js","list.test.js","search.test.js","about.test.js","register.test.js","login-withpwd.test.js","userinfo.test.js","ucenter.test.js","settings.test.js","pages.test.js"];
study夏羽's avatar
study夏羽 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15
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])];
  }
}
A
Anne_LXM 已提交
16
module.exports = CustomSequencer;