Skip to content

Commit

Permalink
refactor: run tests with Jasmine; update ESLint config; add format/li…
Browse files Browse the repository at this point in the history
…nt scripts
  • Loading branch information
hegemonic committed Dec 16, 2024
1 parent 8505263 commit b4aa23f
Show file tree
Hide file tree
Showing 14 changed files with 935 additions and 678 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintrc.cjs

This file was deleted.

68 changes: 68 additions & 0 deletions Herebyfile.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { execa } from 'execa';
import { task } from 'hereby';
import Jasmine from 'jasmine';
import ConsoleReporter from 'jasmine-console-reporter';
import path from 'path';

const BIN_DIR = 'node_modules/.bin';
const EXECA_OUT = {
stdout: 'inherit',
stderr: 'inherit',
};
const sourceGlob = {
lint: ['*.js', 'lib/**/*.js', 'test/**/*.js'],
tests: ['test/helpers/add-matchers.js', 'test/*.js'],
};

function bin(name) {
return path.join(BIN_DIR, name);
}

export const format = task({
name: 'format',
run: async () => {
await execa(bin('prettier'), ['--write', './']);
},
});

export const lint = task({
name: 'lint',
run: async () => {
await execa(bin('eslint'), [...sourceGlob.lint], EXECA_OUT);
},
});

export const test = task({
name: 'test',
run: async () => {
const jasmine = new Jasmine();
const reporter = new ConsoleReporter({
beep: false,
verbosity: {
disabled: false,
pending: false,
specs: false,
summary: true,
},
});

jasmine.clearReporters();
jasmine.addReporter(reporter);
jasmine.exitOnCompletion = false;
jasmine.loadConfig({
forbidDuplicateNames: true,
random: true,
spec_files: sourceGlob.tests, // eslint-disable-line camelcase
stopSpecOnExpectationFailure: false,
});

await jasmine.execute();
},
});

const lintAndTest = task({
name: 'lint-and-test',
dependencies: [lint, test],
});

export default lintAndTest;
2 changes: 0 additions & 2 deletions catharsis.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ function cachedDescribe(parsedType, options) {
}
}

/* eslint-disable class-methods-use-this */
class Catharsis {
constructor() {
this.Types = require('./lib/types');
Expand Down Expand Up @@ -168,6 +167,5 @@ class Catharsis {
return cachedDescribe(parsedType, options);
}
}
/* eslint-enable class-methods-use-this */

module.exports = new Catharsis();
8 changes: 8 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import jsdoc from '@jsdoc/eslint-config';

export default [
{
ignores: ['lib/parser.js'],
},
...jsdoc,
];
2 changes: 0 additions & 2 deletions lib/stringify.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable class-methods-use-this */

const _ = require('lodash');
const Types = require('./types');

Expand Down
Loading

0 comments on commit b4aa23f

Please sign in to comment.