Skip to content

Commit 025250b

Browse files
committed
Upgrade chai to v6 and chai-as-promised to v8
Chai v6 no longer provides default export, requires named imports
1 parent 0a96b33 commit 025250b

File tree

18 files changed

+42
-115
lines changed

18 files changed

+42
-115
lines changed

package-lock.json

Lines changed: 19 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@
5959
"ajv-formats": "^3.0.1",
6060
"archiver": "^5.3.0",
6161
"async": "^3.2.2",
62-
"chai": "^4.3.4",
63-
"chai-as-promised": "^7.1.1",
62+
"chai": "^6.0.1",
63+
"chai-as-promised": "^8.0.2",
6464
"chai-exclude": "^2.1.0",
6565
"commander": "^9.4.1",
6666
"config": "^4.1.1",

scripts/dataset/export/index.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs/promises';
22
import path from 'path';
33
import { fileURLToPath } from 'url';
44

5-
import chai from 'chai';
5+
import { expect, use } from 'chai';
66
import config from 'config';
77
import dircompare from 'dir-compare';
88
import mime from 'mime';
@@ -15,8 +15,6 @@ import generateArchive from './index.js';
1515

1616
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1717

18-
const { expect } = chai;
19-
2018
const FIRST_SERVICE_PROVIDER_ID = 'ServiceA';
2119
const SECOND_SERVICE_PROVIDER_ID = 'ServiceB';
2220

@@ -113,7 +111,7 @@ describe('Export', () => {
113111
});
114112
});
115113

116-
chai.use(chai => {
114+
use(chai => {
117115
const { Assertion } = chai;
118116

119117
Assertion.addMethod('sameContentAs', function (expectedContentPath) {

src/archivist/extract/index.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fsApi from 'fs';
22
import path from 'path';
33
import { fileURLToPath } from 'url';
44

5-
import chai from 'chai';
5+
import { expect } from 'chai';
66
import mime from 'mime';
77

88
import SourceDocument from '../services/sourceDocument.js';
@@ -13,7 +13,6 @@ import extract from './index.js';
1313

1414
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1515
const fs = fsApi.promises;
16-
const { expect } = chai;
1716

1817
const virtualLocation = 'https://example.com/main';
1918
const rawHTML = `

src/archivist/fetcher/fullDomFetcher.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import http from 'http';
22

3-
import chai from 'chai';
3+
import { expect, use } from 'chai';
44
import chaiAsPromised from 'chai-as-promised';
55

66
import fetch, { launchHeadlessBrowser, stopHeadlessBrowser } from './fullDomFetcher.js';
77

8-
const { expect } = chai;
98
const SERVER_PORT = 8977;
109

11-
chai.use(chaiAsPromised);
10+
use(chaiAsPromised);
1211

1312
const dynamicHTML = '<!DOCTYPE html><html><head><title>Dynamic Page</title><script>setTimeout(() => { document.body.innerHTML += "<div class=\'dynamic\'>Loaded</div>"; }, 100);</script></head><body></body></html>';
1413
const delayedContentHTML = '<!DOCTYPE html><html><head><title>Delayed Content</title><script>setTimeout(() => { document.querySelector(".content").textContent = "Final content"; }, 100);</script></head><body><div class="content"></div></body></html>';

src/archivist/fetcher/index.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ import http from 'http';
33
import path from 'path';
44
import { fileURLToPath } from 'url';
55

6-
import chai from 'chai';
6+
import { expect, use } from 'chai';
77
import chaiAsPromised from 'chai-as-promised';
88
import iconv from 'iconv-lite';
99

1010
import fetch, { launchHeadlessBrowser, stopHeadlessBrowser, FetchDocumentError, FETCHER_TYPES } from './index.js';
1111

1212
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1313

14-
const { expect } = chai;
1514
const SERVER_PORT = 8976;
1615

17-
chai.use(chaiAsPromised);
16+
use(chaiAsPromised);
1817

1918
const termsHTML = '<!DOCTYPE html><html><head><meta charset="UTF-8"><title>First provider TOS</title></head><body><h1>Terms of service</h1><p>Dapibus quis diam sagittis</p></body></html>';
2019
const termsWithOtherCharsetHTML = '<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>TOS на първия доставчик</title></head><body><h1>Условия за ползване</h1><p>Dapibus quis diam sagittis</p></body></html>';

src/archivist/index.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fsApi from 'fs';
22
import path from 'path';
33
import { fileURLToPath } from 'url';
44

5-
import chai from 'chai';
5+
import { expect, use } from 'chai';
66
import config from 'config';
77
import nock from 'nock';
88
import sinon from 'sinon';
@@ -16,8 +16,7 @@ import Archivist, { EVENTS } from './index.js';
1616

1717
const fs = fsApi.promises;
1818

19-
chai.use(sinonChai);
20-
const { expect } = chai;
19+
use(sinonChai);
2120

2221
const __dirname = path.dirname(fileURLToPath(import.meta.url));
2322

src/archivist/recorder/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import chai from 'chai';
1+
import { expect } from 'chai';
22
import config from 'config';
33

44
import Snapshot from './snapshot.js';
55
import Version from './version.js';
66

77
import Recorder from './index.js';
88

9-
const { expect } = chai;
10-
119
const MIME_TYPE = 'text/html';
1210
const FETCH_DATE = new Date('2000-01-01T12:00:00.000Z');
1311
const FETCH_DATE_LATER = new Date('2000-01-02T12:00:00.000Z');

src/archivist/recorder/repositories/git/index.test.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs';
22
import path from 'path';
33
import { fileURLToPath } from 'url';
44

5-
import chai from 'chai';
5+
import { expect } from 'chai';
66
import config from 'config';
77
import mime from 'mime';
88

@@ -14,8 +14,6 @@ import Git from './git.js';
1414

1515
import GitRepository from './index.js';
1616

17-
const { expect } = chai;
18-
1917
const __dirname = path.dirname(fileURLToPath(import.meta.url));
2018

2119
const RECORDER_PATH = path.resolve(__dirname, '../../../../..', config.get('@opentermsarchive/engine.recorder.versions.storage.git.path'));

src/archivist/recorder/repositories/mongo/index.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'fs';
22
import path from 'path';
33
import { fileURLToPath } from 'url';
44

5-
import chai from 'chai';
5+
import { expect } from 'chai';
66
import config from 'config';
77
import mime from 'mime';
88
import { MongoClient } from 'mongodb';
@@ -12,7 +12,6 @@ import Version from '../../version.js';
1212

1313
import MongoRepository from './index.js';
1414

15-
const { expect } = chai;
1615
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1716

1817
const { connectionURI } = config.get('@opentermsarchive/engine.recorder.snapshots.storage.mongo');

0 commit comments

Comments
 (0)