Skip to content

Commit 9cedc97

Browse files
authored
Update dependencies and such
* Update dev dependencies * Test with TypeScript 4.2 * Upgrade to XO 0.38 * Update dependencies * Rebuild lockfile * Assume npm 7.6.3
1 parent c5bada9 commit 9cedc97

File tree

21 files changed

+1357
-1587
lines changed

21 files changed

+1357
-1587
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
runs-on: ubuntu-latest
4444
strategy:
4545
matrix:
46-
ts-version: [~4.1]
46+
ts-version: [~4.2]
4747
steps:
4848
- uses: actions/checkout@v2
4949
with:
@@ -71,7 +71,7 @@ jobs:
7171
with:
7272
node-version: ^12.20
7373
- name: Upgrade npm
74-
run: if [[ "$(npm -v)" != "7.5.2" ]]; then npm install --global npm@7.5.2; fi
74+
run: if [[ "$(npm -v)" != "7.6.3" ]]; then npm install --global npm@7.6.3; fi
7575
- run: npm ci --no-audit
7676
- name: Test package-lock for unexpected modifications
7777
run: |

docs/recipes/typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Translations: [Español](https://github.com/avajs/ava-docs/blob/master/es_ES/doc
44

55
AVA comes bundled with a TypeScript definition file. This allows developers to leverage TypeScript for writing tests.
66

7-
This guide assumes you've already set up TypeScript for your project. Note that AVA 3's definition expects at least version 3.7.5. AVA 4 will require at least version 4.1.
7+
This guide assumes you've already set up TypeScript for your project. Note that AVA 3's definition expects at least version 3.7.5. AVA 4 will require at least version 4.2.
88

99
## Enabling AVA's support for TypeScript test files
1010

lib/line-numbers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const sortNumbersAscending = array => {
1717

1818
const parseNumber = string => Number.parseInt(string, 10);
1919
const removeAllWhitespace = string => string.replace(/\s/g, '');
20-
const range = (start, end) => new Array(end - start + 1).fill(start).map((element, index) => element + index);
20+
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);
2121

2222
const parseLineNumbers = suffix => sortNumbersAscending(distinctArray(flatten(
2323
suffix.split(',').map(part => {

lib/runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ class Runner extends Emittery {
281281
failWithoutAssertions: false,
282282
fn: task.args.length === 0 ?
283283
task.implementation :
284-
t => task.implementation.apply(null, [t].concat(task.args)),
284+
t => Reflect.apply(task.implementation, null, [t, ...task.args]),
285285
compareTestSnapshot: this.boundCompareTestSnapshot,
286286
skipSnapshot: this.boundSkipSnapshot,
287287
updateSnapshots: this.updateSnapshots,
@@ -333,7 +333,7 @@ class Runner extends Emittery {
333333
failWithoutAssertions: this.failWithoutAssertions,
334334
fn: task.args.length === 0 ?
335335
task.implementation :
336-
t => task.implementation.apply(null, [t].concat(task.args)),
336+
t => Reflect.apply(task.implementation, null, [t, ...task.args]),
337337
compareTestSnapshot: this.boundCompareTestSnapshot,
338338
skipSnapshot: this.boundSkipSnapshot,
339339
updateSnapshots: this.updateSnapshots,

lib/scheduler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ module.exports.failingTestsFirst = (selectedFiles, cacheDir, cacheEnabled) => {
3030
}
3131

3232
return [...selectedFiles].sort((f, s) => {
33-
if (failedTestFiles.some(tf => tf === f) && failedTestFiles.some(tf => tf === s)) {
33+
if (failedTestFiles.includes(f) && failedTestFiles.includes(s)) {
3434
return 0;
3535
}
3636

37-
if (failedTestFiles.some(tf => tf === f)) {
37+
if (failedTestFiles.includes(f)) {
3838
return -1;
3939
}
4040

41-
if (failedTestFiles.some(tf => tf === s)) {
41+
if (failedTestFiles.includes(s)) {
4242
return 1;
4343
}
4444

lib/watcher.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Watcher {
105105
// The test files that previously contained exclusive tests are always
106106
// run, together with the remaining specific files.
107107
const remainingFiles = diff(specificFiles, exclusiveFiles);
108-
specificFiles = this.filesWithExclusiveTests.concat(remainingFiles);
108+
specificFiles = [...this.filesWithExclusiveTests, ...remainingFiles];
109109
}
110110

111111
if (filter.length > 0) {
@@ -440,7 +440,7 @@ class Watcher {
440440
}
441441

442442
// Run all affected tests
443-
this.run([...new Set(addedOrChangedTests.concat(flatten(testsByHelpersOrSource)))]);
443+
this.run([...new Set([...addedOrChangedTests, ...flatten(testsByHelpersOrSource)])]);
444444
}
445445
}
446446

lib/worker/base.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,9 @@ const run = async options => {
117117
}
118118

119119
nowAndTimers.setImmediate(() => {
120-
currentlyUnhandled()
121-
.filter(rejection => !attributedRejections.has(rejection.promise))
122-
.forEach(rejection => {
123-
channel.send({type: 'unhandled-rejection', err: serializeError('Unhandled rejection', true, rejection.reason, runner.file)});
124-
});
120+
for (const rejection of currentlyUnhandled().filter(rejection => !attributedRejections.has(rejection.promise))) {
121+
channel.send({type: 'unhandled-rejection', err: serializeError('Unhandled rejection', true, rejection.reason, runner.file)});
122+
}
125123

126124
exit(0);
127125
});

lib/worker/line-numbers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function findTest(locations, declaration) {
4949
return spans.pop();
5050
}
5151

52-
const range = (start, end) => new Array(end - start + 1).fill(start).map((element, index) => element + index);
52+
const range = (start, end) => Array.from({length: end - start + 1}).fill(start).map((element, index) => element + index);
5353

5454
module.exports = ({file, lineNumbers = []}) => {
5555
if (lineNumbers.length === 0) {

0 commit comments

Comments
 (0)