Skip to content

Commit

Permalink
chore: replace mocha with vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvetomir committed Jan 2, 2025
1 parent d8f8070 commit 23b74ee
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 166 deletions.
6 changes: 0 additions & 6 deletions .mocharc.js

This file was deleted.

7 changes: 2 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"sideEffects": false,
"scripts": {
"build-package": "rollup -c",
"test": "mocha",
"test": "vitest --run",
"lint": "eslint",
"prepare": "husky"
},
Expand All @@ -30,7 +30,6 @@
"Jean-loup Gailly",
"Mark Adler"
],
"dependencies": {},
"devDependencies": {
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
Expand All @@ -39,11 +38,9 @@
"eslint": "^9.17.0",
"globals": "^15.14.0",
"husky": "^9.1.7",
"mocha": "^7.1.1",
"reify": "^0.20.12",
"rollup": "^4.29.1",
"semantic-release": "^24.2.0",
"zlibjs": "^0.3.1"
"vitest": "^2.1.8"
},
"repository": {
"type": "git",
Expand Down
56 changes: 0 additions & 56 deletions test/browser/test.html

This file was deleted.

42 changes: 0 additions & 42 deletions test/browser/test.js

This file was deleted.

10 changes: 3 additions & 7 deletions test/chunks.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
/*global describe, it*/


'use strict';

import { assert, describe, it } from 'vitest';

import assert from 'assert';
import helpers from './helpers';
import { arraySet, Buf8 } from '../lib/utils/common';
import pako from '../lib/main';

import * as pako from '../lib/main';
import * as helpers from './helpers';

var samples = helpers.loadSamples();

Expand Down
9 changes: 3 additions & 6 deletions test/deflate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/*global describe, it*/


'use strict';

import { assert, describe, it } from 'vitest';

import zlib from 'zlib';
import pako from '../lib/main';
import helpers from './helpers';
import assert from 'assert';
import * as pako from '../lib/main';
import * as helpers from './helpers';
import fs from 'fs';
import path from 'path';
import b from 'buffer-from';
Expand Down
12 changes: 4 additions & 8 deletions test/deflate_cover.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
// Deflate coverage tests

/*global describe, it*/


'use strict';

import { assert, describe, it } from 'vitest';

import assert from 'assert';
import fs from 'fs';
import path from 'path';
import c from '../lib/zlib/constants';
import * as pako from '../lib/main';
import * as c from '../lib/zlib/constants';
import msg from '../lib/zlib/messages';
import zlib_deflate from '../lib/zlib/deflate';
import * as zlib_deflate from '../lib/zlib/deflate';
import ZStream from '../lib/zlib/zstream';
import pako from '../lib/main';


var short_sample = 'hello world';
Expand Down
7 changes: 2 additions & 5 deletions test/gzip_specials.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/*global describe, it*/


'use strict';

import { assert, describe, it } from 'vitest';

import fs from 'fs';
import path from 'path';
import assert from 'assert';
import { arraySet, Buf8 } from '../lib/utils/common';
import pako from '../lib/main';
import * as pako from '../lib/main';
import { cmpBuf as cmp } from './helpers';


Expand Down
8 changes: 3 additions & 5 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
'use strict';


import { assert } from 'vitest';
import fs from 'fs';
import path from 'path';
import assert from 'assert';
import b from 'buffer-from';
import { setTyped, Buf8 } from '../lib/utils/common';
import pako from '../lib/main';
import * as pako from '../lib/main';

// Load fixtures to test
// return: { 'filename1': content1, 'filename2': content2, ...}
Expand Down Expand Up @@ -65,7 +64,7 @@ function testSingle(zlib_method, pako_method, data, options) {
// position (= no additional gzip headers used)
if (options.ignore_os) zlib_result[9] = pako_result[9];

assert.deepEqual(pako_result, zlib_result);
assert.deepEqual(new Uint8Array(pako_result), zlib_result);
}


Expand Down Expand Up @@ -110,5 +109,4 @@ function testInflate(samples, inflateOptions, deflateOptions) {
}
}


export { cmpBuf, testSamples, testInflate, loadSamples };
9 changes: 3 additions & 6 deletions test/inflate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/*global describe, it*/


'use strict';


import { assert, describe, it } from 'vitest';
import zlib from 'zlib';
import assert from 'assert';
import pako from '../lib/main';
import helpers from './helpers';
import * as pako from '../lib/main';
import * as helpers from './helpers';
var testInflate = helpers.testInflate;


Expand Down
12 changes: 4 additions & 8 deletions test/inflate_cover_ported.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
// This tests are ported from original zlib

/*global describe, it*/


'use strict';

import { assert, describe, it } from 'vitest';

import assert from 'assert';
import c from '../lib/zlib/constants';
import * as c from '../lib/zlib/constants';
import msg from '../lib/zlib/messages';

//var zlib_stream = require('../lib/zlib/zstream');
import zlib_inflate from '../lib/zlib/inflate';
import * as zlib_inflate from '../lib/zlib/inflate';

import inflate_table from '../lib/zlib/inftrees';
import pako from '../lib/main';
import * as pako from '../lib/main';


function h2b(hex) {
Expand Down
7 changes: 2 additions & 5 deletions test/misc.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
/*global describe, it*/


'use strict';


import { assert, describe, it } from 'vitest';
import fs from 'fs';
import path from 'path';
import assert from 'assert';
import pako from '../lib/main';
import * as pako from '../lib/main';
import { cmpBuf as cmp } from './helpers';

describe('ArrayBuffer', function () {
Expand Down
10 changes: 3 additions & 7 deletions test/strings.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/*global describe, it*/


'use strict';


import { assert, describe, it } from 'vitest';
import fs from 'fs';
import path from 'path';
import assert from 'assert';
import b from 'buffer-from';
import pako from '../lib/main';
import * as pako from '../lib/main';
import { cmpBuf as cmp } from './helpers';
import strings from '../lib/utils/strings';
import * as strings from '../lib/utils/strings';

// fromCharCode, but understands right > 0xffff values
function fixedFromCharCode(code) {
Expand Down
8 changes: 8 additions & 0 deletions vitest.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
test: {
include: ['test/**/*.js'],
exclude: ['test/helpers.js']
},
})

0 comments on commit 23b74ee

Please sign in to comment.