(files: TestSpecification[])
| 14 | |
| 15 | // async so it can be extended by other sequencers |
| 16 | public async shard(files: TestSpecification[]): Promise<TestSpecification[]> { |
| 17 | const { config } = this.ctx |
| 18 | const { index, count } = config.shard! |
| 19 | const [shardStart, shardEnd] = this.calculateShardRange(files.length, index, count) |
| 20 | return [...files] |
| 21 | .map((spec) => { |
| 22 | const fullPath = resolve(slash(config.root), slash(spec.moduleId)) |
| 23 | const specPath = fullPath?.slice(config.root.length) |
| 24 | return { |
| 25 | spec, |
| 26 | hash: hash('sha1', specPath, 'hex'), |
| 27 | } |
| 28 | }) |
| 29 | .sort((a, b) => (a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0)) |
| 30 | .slice(shardStart, shardEnd) |
| 31 | .map(({ spec }) => spec) |
| 32 | } |
| 33 | |
| 34 | // async so it can be extended by other sequencers |
| 35 | public async sort(files: TestSpecification[]): Promise<TestSpecification[]> { |
no test coverage detected