Skip to content

Commit

Permalink
Switch to mocha tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed Feb 24, 2024
1 parent 238e809 commit f8850db
Show file tree
Hide file tree
Showing 10 changed files with 388 additions and 422 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ jobs:

strategy:
matrix:
latest-node-version: [16.x]
node-version: [16.x]
latest-node-version: [20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 4 additions & 0 deletions .mocharc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
spec: ['test/**/*.test.ts'],
'node-option': ['import=tsx'],
};
7 changes: 0 additions & 7 deletions ava.config.mjs

This file was deleted.

10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,26 @@
"prepublishOnly": "npm run preversion",
"preversion": "run-s test build",
"test": "run-s -n test:lint test:only",
"test:debug": "ava debug",
"test:debug": "mocha --inspect-brk",
"test:lint": "run-s -n test:lint:*",
"test:lint:prettier": "prettier --check '{src,test}/**/*.ts' '**/*.md'",
"test:lint:ts": "eslint '{src,test}/**/*.ts'",
"test:only": "c8 ava",
"test:watch": "ava --watch"
"test:only": "c8 mocha",
"test:watch": "mocha --watch"
},
"devDependencies": {
"@rollup/plugin-typescript": "11.1.6",
"@types/mocha": "10.0.6",
"@types/node": "20.11.20",
"@typescript-eslint/eslint-plugin": "6.18.1",
"@typescript-eslint/parser": "6.18.1",
"ava": "6.0.1",
"benchmark": "2.1.4",
"c8": "9.0.0",
"esbuild": "0.19.11",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-no-only-tests": "3.1.0",
"mocha": "10.3.0",
"npm-run-all": "4.1.5",
"prettier": "3.1.1",
"rollup": "4.9.4",
Expand Down
38 changes: 18 additions & 20 deletions test/any-map.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference lib="esnext" />

import { test, describe } from './setup';
import { strict as assert } from 'assert';
import { AnyMap, encodedMappings, decodedMappings } from '../src/trace-mapping';

import type { SectionedSourceMap, SourceMapSegment } from '../src/trace-mapping';
Expand Down Expand Up @@ -70,39 +70,39 @@ describe('AnyMap', () => {
};

describe('map properties', () => {
test('version', (t) => {
it('version', () => {
const tracer = new AnyMap(map);
t.is(tracer.version, map.version);
assert.equal(tracer.version, map.version);
});

test('file', (t) => {
it('file', () => {
const tracer = new AnyMap(map);
t.is(tracer.file, map.file);
assert.equal(tracer.file, map.file);
});

test('sourceRoot', (t) => {
it('sourceRoot', () => {
const tracer = new AnyMap(map);
t.is(tracer.sourceRoot, undefined);
assert.equal(tracer.sourceRoot, undefined);
});

test('sources', (t) => {
it('sources', () => {
const tracer = new AnyMap(map);
t.deepEqual(tracer.sources, ['first.js', 'second.js', 'nested/third.js', 'fourth.js']);
assert.deepEqual(tracer.sources, ['first.js', 'second.js', 'nested/third.js', 'fourth.js']);
});

test('names', (t) => {
it('names', () => {
const tracer = new AnyMap(map);
t.deepEqual(tracer.names, ['first', 'second', 'third']);
assert.deepEqual(tracer.names, ['first', 'second', 'third']);
});

test('encodedMappings', (t) => {
it('encodedMappings', () => {
const tracer = new AnyMap(map);
t.is(encodedMappings(tracer), ';EAAAA,CCAAC;ACAAC,CCAA');
assert.equal(encodedMappings(tracer), ';EAAAA,CCAAC;ACAAC,CCAA');
});

test('decodedMappings', (t) => {
it('decodedMappings', () => {
const tracer = new AnyMap(map);
t.deepEqual(decodedMappings(tracer), [
assert.deepEqual(decodedMappings(tracer), [
[],
[
[2, 0, 0, 0, 0],
Expand All @@ -115,9 +115,9 @@ describe('AnyMap', () => {
]);
});

test('sourcesContent', (t) => {
it('sourcesContent', () => {
const tracer = new AnyMap(map);
t.deepEqual(tracer.sourcesContent, [
assert.deepEqual(tracer.sourcesContent, [
'firstsource',
'secondsource',
'thirdsource',
Expand All @@ -127,10 +127,8 @@ describe('AnyMap', () => {
});

describe('typescript readonly type', () => {
test('decoded source map', (t) => {
it('decoded source map', () => {
// This is a TS lint test, not a real one.
t.pass();

const decodedMap = {
version: 3 as const,
sources: ['input.js'] as readonly string[],
Expand Down
Loading

0 comments on commit f8850db

Please sign in to comment.