mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01:00
feat: use vitest instead of jest for more speed
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -26,6 +26,7 @@ dist/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
.turbo
|
.turbo
|
||||||
tsconfig.tsbuildinfo
|
tsconfig.tsbuildinfo
|
||||||
|
coverage/
|
||||||
|
|
||||||
# yarn
|
# yarn
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "turbo run build",
|
"build": "turbo run build",
|
||||||
"test": "turbo run test",
|
"test": "turbo run test && vitest run",
|
||||||
"lint": "turbo run lint",
|
"lint": "turbo run lint",
|
||||||
"format": "turbo run format",
|
"format": "turbo run format",
|
||||||
"fmt": "turbo run format",
|
"fmt": "turbo run format",
|
||||||
@@ -41,10 +41,13 @@
|
|||||||
"@commitlint/cli": "^17.0.2",
|
"@commitlint/cli": "^17.0.2",
|
||||||
"@commitlint/config-angular": "^17.0.0",
|
"@commitlint/config-angular": "^17.0.0",
|
||||||
"@favware/npm-deprecate": "^1.0.4",
|
"@favware/npm-deprecate": "^1.0.4",
|
||||||
|
"c8": "^7.11.3",
|
||||||
"conventional-changelog-cli": "^2.2.2",
|
"conventional-changelog-cli": "^2.2.2",
|
||||||
"husky": "^8.0.1",
|
"husky": "^8.0.1",
|
||||||
|
"is-ci": "^3.0.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"turbo": "^1.2.16"
|
"turbo": "^1.2.16",
|
||||||
|
"vitest": "^0.13.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.9.0"
|
"node": ">=16.9.0"
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import { formatTag } from '../src';
|
import { formatTag } from '../src';
|
||||||
|
|
||||||
describe('Format Tag', () => {
|
describe('Format Tag', () => {
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@babel/core').TransformOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
parserOpts: { strictMode: true },
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
targets: { node: 'current' },
|
|
||||||
modules: 'commonjs',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'@babel/preset-typescript',
|
|
||||||
],
|
|
||||||
plugins: ['babel-plugin-transform-typescript-metadata', ['@babel/plugin-proposal-decorators', { legacy: true }]],
|
|
||||||
};
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@jest/types').Config.InitialOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
collectCoverage: true,
|
|
||||||
collectCoverageFrom: ['src/**/*.ts'],
|
|
||||||
coverageDirectory: 'coverage',
|
|
||||||
coverageReporters: ['text', 'lcov', 'clover'],
|
|
||||||
coverageThreshold: {
|
|
||||||
global: {
|
|
||||||
branches: 70,
|
|
||||||
lines: 70,
|
|
||||||
statements: 70,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
coveragePathIgnorePatterns: ['src/index.ts', 'src/formatTag/index.ts'],
|
|
||||||
};
|
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"test": "jest --pass-with-no-tests",
|
|
||||||
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix"
|
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix"
|
||||||
},
|
},
|
||||||
@@ -48,20 +47,13 @@
|
|||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
|
||||||
"@babel/plugin-proposal-decorators": "^7.18.2",
|
|
||||||
"@babel/preset-env": "^7.18.2",
|
|
||||||
"@babel/preset-typescript": "^7.17.12",
|
|
||||||
"@types/jest": "^28.1.0",
|
|
||||||
"@types/node": "^16.11.38",
|
"@types/node": "^16.11.38",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^5.27.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
||||||
"eslint": "^8.17.0",
|
"eslint": "^8.17.0",
|
||||||
"eslint-config-marine": "^9.4.1",
|
"eslint-config-marine": "^9.4.1",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"jest": "^28.1.0",
|
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"tsup": "^6.0.1",
|
"tsup": "^6.0.1",
|
||||||
"typescript": "^4.7.3"
|
"typescript": "^4.7.3"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { APIActionRowComponent, APIMessageActionRowComponent, ButtonStyle, ComponentType } from 'discord-api-types/v10';
|
import { APIActionRowComponent, APIMessageActionRowComponent, ButtonStyle, ComponentType } from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
@@ -82,6 +83,7 @@ describe('Action Row Components', () => {
|
|||||||
expect(new ActionRowBuilder().toJSON()).toEqual({ type: ComponentType.ActionRow, components: [] });
|
expect(new ActionRowBuilder().toJSON()).toEqual({ type: ComponentType.ActionRow, components: [] });
|
||||||
expect(() => createComponentBuilder({ type: ComponentType.ActionRow, components: [] })).not.toThrowError();
|
expect(() => createComponentBuilder({ type: ComponentType.ActionRow, components: [] })).not.toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN valid builder options THEN valid JSON output is given', () => {
|
test('GIVEN valid builder options THEN valid JSON output is given', () => {
|
||||||
const rowWithButtonData: APIActionRowComponent<APIMessageActionRowComponent> = {
|
const rowWithButtonData: APIActionRowComponent<APIMessageActionRowComponent> = {
|
||||||
type: ComponentType.ActionRow,
|
type: ComponentType.ActionRow,
|
||||||
@@ -122,7 +124,8 @@ describe('Action Row Components', () => {
|
|||||||
expect(new ActionRowBuilder().toJSON()).toEqual({ type: ComponentType.ActionRow, components: [] });
|
expect(new ActionRowBuilder().toJSON()).toEqual({ type: ComponentType.ActionRow, components: [] });
|
||||||
expect(() => createComponentBuilder({ type: ComponentType.ActionRow, components: [] })).not.toThrowError();
|
expect(() => createComponentBuilder({ type: ComponentType.ActionRow, components: [] })).not.toThrowError();
|
||||||
});
|
});
|
||||||
test('GIVEN valid builder options THEN valid JSON output is given', () => {
|
|
||||||
|
test('GIVEN valid builder options THEN valid JSON output is given 2', () => {
|
||||||
const button = new ButtonBuilder().setLabel('test').setStyle(ButtonStyle.Primary).setCustomId('123');
|
const button = new ButtonBuilder().setLabel('test').setStyle(ButtonStyle.Primary).setCustomId('123');
|
||||||
const selectMenu = new SelectMenuBuilder()
|
const selectMenu = new SelectMenuBuilder()
|
||||||
.setCustomId('1234')
|
.setCustomId('1234')
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
ButtonStyle,
|
ButtonStyle,
|
||||||
ComponentType,
|
ComponentType,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import { buttonLabelValidator, buttonStyleValidator } from '../../src/components/Assertions';
|
import { buttonLabelValidator, buttonStyleValidator } from '../../src/components/Assertions';
|
||||||
import { ButtonBuilder } from '../../src/components/button/Button';
|
import { ButtonBuilder } from '../../src/components/button/Button';
|
||||||
|
|
||||||
@@ -124,7 +125,7 @@ describe('Button Components', () => {
|
|||||||
expect(
|
expect(
|
||||||
buttonComponent()
|
buttonComponent()
|
||||||
.setCustomId(interactionData.custom_id)
|
.setCustomId(interactionData.custom_id)
|
||||||
.setLabel(interactionData.label)
|
.setLabel(interactionData.label!)
|
||||||
.setStyle(interactionData.style)
|
.setStyle(interactionData.style)
|
||||||
.setDisabled(interactionData.disabled)
|
.setDisabled(interactionData.disabled)
|
||||||
.toJSON(),
|
.toJSON(),
|
||||||
@@ -140,7 +141,7 @@ describe('Button Components', () => {
|
|||||||
|
|
||||||
expect(new ButtonBuilder(linkData).toJSON()).toEqual(linkData);
|
expect(new ButtonBuilder(linkData).toJSON()).toEqual(linkData);
|
||||||
|
|
||||||
expect(buttonComponent().setLabel(linkData.label).setDisabled(true).setURL(linkData.url));
|
expect(buttonComponent().setLabel(linkData.label!).setDisabled(true).setURL(linkData.url));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { APISelectMenuComponent, APISelectMenuOption, ComponentType } from 'discord-api-types/v10';
|
import { APISelectMenuComponent, APISelectMenuOption, ComponentType } from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import { SelectMenuBuilder, SelectMenuOptionBuilder } from '../../src/index';
|
import { SelectMenuBuilder, SelectMenuOptionBuilder } from '../../src/index';
|
||||||
|
|
||||||
const selectMenu = () => new SelectMenuBuilder();
|
const selectMenu = () => new SelectMenuBuilder();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { APITextInputComponent, ComponentType, TextInputStyle } from 'discord-api-types/v10';
|
import { APITextInputComponent, ComponentType, TextInputStyle } from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import {
|
import {
|
||||||
labelValidator,
|
labelValidator,
|
||||||
maxLengthValidator,
|
maxLengthValidator,
|
||||||
@@ -45,7 +46,7 @@ describe('Text Input Components', () => {
|
|||||||
expect(() => maxLengthValidator.parse(10)).not.toThrowError();
|
expect(() => maxLengthValidator.parse(10)).not.toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN invalid min length THEN validator does throw', () => {
|
test('GIVEN invalid min length THEN validator does throw 2', () => {
|
||||||
expect(() => maxLengthValidator.parse(4001)).toThrowError();
|
expect(() => maxLengthValidator.parse(4001)).toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -61,7 +62,7 @@ describe('Text Input Components', () => {
|
|||||||
expect(() => placeholderValidator.parse('foobar')).not.toThrowError();
|
expect(() => placeholderValidator.parse('foobar')).not.toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN invalid value THEN validator does throw', () => {
|
test('GIVEN invalid value THEN validator does throw 2', () => {
|
||||||
expect(() => placeholderValidator.parse(superLongStr)).toThrowError();
|
expect(() => placeholderValidator.parse(superLongStr)).toThrowError();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -114,10 +115,10 @@ describe('Text Input Components', () => {
|
|||||||
textInputComponent()
|
textInputComponent()
|
||||||
.setCustomId(textInputData.custom_id)
|
.setCustomId(textInputData.custom_id)
|
||||||
.setLabel(textInputData.label)
|
.setLabel(textInputData.label)
|
||||||
.setPlaceholder(textInputData.placeholder)
|
.setPlaceholder(textInputData.placeholder!)
|
||||||
.setMaxLength(textInputData.max_length)
|
.setMaxLength(textInputData.max_length!)
|
||||||
.setMinLength(textInputData.min_length)
|
.setMinLength(textInputData.min_length!)
|
||||||
.setValue(textInputData.value)
|
.setValue(textInputData.value!)
|
||||||
.setRequired(textInputData.required)
|
.setRequired(textInputData.required)
|
||||||
.setStyle(textInputData.style)
|
.setStyle(textInputData.style)
|
||||||
.toJSON(),
|
.toJSON(),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { PermissionFlagsBits } from 'discord-api-types/v10';
|
import { PermissionFlagsBits } from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import { ContextMenuCommandAssertions, ContextMenuCommandBuilder } from '../../src/index';
|
import { ContextMenuCommandAssertions, ContextMenuCommandBuilder } from '../../src/index';
|
||||||
|
|
||||||
const getBuilder = () => new ContextMenuCommandBuilder();
|
const getBuilder = () => new ContextMenuCommandBuilder();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
ApplicationCommandOptionType,
|
ApplicationCommandOptionType,
|
||||||
ChannelType,
|
ChannelType,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import {
|
import {
|
||||||
SlashCommandBooleanOption,
|
SlashCommandBooleanOption,
|
||||||
SlashCommandChannelOption,
|
SlashCommandChannelOption,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { APIApplicationCommandOptionChoice, ChannelType, PermissionFlagsBits } from 'discord-api-types/v10';
|
import { APIApplicationCommandOptionChoice, ChannelType, PermissionFlagsBits } from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import {
|
import {
|
||||||
SlashCommandAssertions,
|
SlashCommandAssertions,
|
||||||
SlashCommandBooleanOption,
|
SlashCommandBooleanOption,
|
||||||
@@ -313,8 +314,10 @@ describe('Slash Commands', () => {
|
|||||||
// @ts-expect-error Checking if not providing anything, or an invalid return type causes an error
|
// @ts-expect-error Checking if not providing anything, or an invalid return type causes an error
|
||||||
expect(() => getBuilder().addBooleanOption(true)).toThrowError();
|
expect(() => getBuilder().addBooleanOption(true)).toThrowError();
|
||||||
|
|
||||||
|
// @ts-expect-error Checking if not providing anything, or an invalid return type causes an error
|
||||||
expect(() => getBuilder().addBooleanOption(null)).toThrowError();
|
expect(() => getBuilder().addBooleanOption(null)).toThrowError();
|
||||||
|
|
||||||
|
// @ts-expect-error Checking if not providing anything, or an invalid return type causes an error
|
||||||
expect(() => getBuilder().addBooleanOption(undefined)).toThrowError();
|
expect(() => getBuilder().addBooleanOption(undefined)).toThrowError();
|
||||||
|
|
||||||
// @ts-expect-error Checking if not providing anything, or an invalid return type causes an error
|
// @ts-expect-error Checking if not providing anything, or an invalid return type causes an error
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { APIModalInteractionResponseCallbackData, ComponentType, TextInputStyle } from 'discord-api-types/v10';
|
import { APIModalInteractionResponseCallbackData, ComponentType, TextInputStyle } from 'discord-api-types/v10';
|
||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import {
|
import {
|
||||||
ActionRowBuilder,
|
ActionRowBuilder,
|
||||||
ButtonBuilder,
|
ButtonBuilder,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import { EmbedBuilder, embedLength } from '../../src';
|
import { EmbedBuilder, embedLength } from '../../src';
|
||||||
|
|
||||||
const alpha = 'abcdefghijklmnopqrstuvwxyz';
|
const alpha = 'abcdefghijklmnopqrstuvwxyz';
|
||||||
@@ -341,7 +342,7 @@ describe('Embed', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN an embed using Embed#spliceFields THEN returns valid toJSON data', () => {
|
test('GIVEN an embed using Embed#spliceFields THEN returns valid toJSON data 2', () => {
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
embed.addFields(Array.from({ length: 23 }, () => ({ name: 'foo', value: 'bar' })));
|
embed.addFields(Array.from({ length: 23 }, () => ({ name: 'foo', value: 'bar' })));
|
||||||
|
|
||||||
@@ -374,7 +375,7 @@ describe('Embed', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('GIVEN invalid field amount THEN throws error', () => {
|
describe('GIVEN invalid field amount THEN throws error', () => {
|
||||||
test('', () => {
|
test('1', () => {
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
|
|
||||||
expect(() => embed.addFields(Array.from({ length: 26 }, () => ({ name: 'foo', value: 'bar' })))).toThrowError();
|
expect(() => embed.addFields(Array.from({ length: 26 }, () => ({ name: 'foo', value: 'bar' })))).toThrowError();
|
||||||
@@ -382,7 +383,7 @@ describe('Embed', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('GIVEN invalid field name THEN throws error', () => {
|
describe('GIVEN invalid field name THEN throws error', () => {
|
||||||
test('', () => {
|
test('2', () => {
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
|
|
||||||
expect(() => embed.addFields([{ name: '', value: 'bar' }])).toThrowError();
|
expect(() => embed.addFields([{ name: '', value: 'bar' }])).toThrowError();
|
||||||
@@ -390,7 +391,7 @@ describe('Embed', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('GIVEN invalid field name length THEN throws error', () => {
|
describe('GIVEN invalid field name length THEN throws error', () => {
|
||||||
test('', () => {
|
test('3', () => {
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
|
|
||||||
expect(() => embed.addFields([{ name: 'a'.repeat(257), value: 'bar' }])).toThrowError();
|
expect(() => embed.addFields([{ name: 'a'.repeat(257), value: 'bar' }])).toThrowError();
|
||||||
@@ -398,7 +399,7 @@ describe('Embed', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('GIVEN invalid field value length THEN throws error', () => {
|
describe('GIVEN invalid field value length THEN throws error', () => {
|
||||||
test('', () => {
|
test('4', () => {
|
||||||
const embed = new EmbedBuilder();
|
const embed = new EmbedBuilder();
|
||||||
|
|
||||||
expect(() => embed.addFields([{ name: '', value: 'a'.repeat(1025) }])).toThrowError();
|
expect(() => embed.addFields([{ name: '', value: 'a'.repeat(1025) }])).toThrowError();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { describe, test, expect, vitest } from 'vitest';
|
||||||
import {
|
import {
|
||||||
blockQuote,
|
blockQuote,
|
||||||
bold,
|
bold,
|
||||||
@@ -150,12 +151,12 @@ describe('Message formatters', () => {
|
|||||||
|
|
||||||
describe('time', () => {
|
describe('time', () => {
|
||||||
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
|
test('GIVEN no arguments THEN returns "<t:${bigint}>"', () => {
|
||||||
jest.useFakeTimers('modern');
|
vitest.useFakeTimers();
|
||||||
jest.setSystemTime(1566424897579);
|
vitest.setSystemTime(1566424897579);
|
||||||
|
|
||||||
expect<`<t:${bigint}>`>(time()).toEqual('<t:1566424897>');
|
expect<`<t:${bigint}>`>(time()).toEqual('<t:1566424897>');
|
||||||
|
|
||||||
jest.useRealTimers();
|
vitest.useRealTimers();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('GIVEN a date THEN returns "<t:${bigint}>"', () => {
|
test('GIVEN a date THEN returns "<t:${bigint}>"', () => {
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@babel/core').TransformOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
parserOpts: { strictMode: true },
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
targets: { node: 'current' },
|
|
||||||
modules: 'commonjs',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'@babel/preset-typescript',
|
|
||||||
],
|
|
||||||
plugins: ['babel-plugin-transform-typescript-metadata', ['@babel/plugin-proposal-decorators', { legacy: true }]],
|
|
||||||
};
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@jest/types').Config.InitialOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
collectCoverage: true,
|
|
||||||
collectCoverageFrom: ['src/**/*.ts'],
|
|
||||||
coverageDirectory: 'coverage',
|
|
||||||
coverageReporters: ['text', 'lcov', 'clover'],
|
|
||||||
coverageThreshold: {
|
|
||||||
global: {
|
|
||||||
branches: 70,
|
|
||||||
lines: 70,
|
|
||||||
statements: 70,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
coveragePathIgnorePatterns: ['src/index.ts'],
|
|
||||||
};
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
"description": "A set of builders that you can use when creating your bot",
|
"description": "A set of builders that you can use when creating your bot",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"test": "jest --pass-with-no-tests",
|
|
||||||
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
|
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
|
||||||
@@ -60,21 +59,14 @@
|
|||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
|
||||||
"@babel/plugin-proposal-decorators": "^7.18.2",
|
|
||||||
"@babel/preset-env": "^7.18.2",
|
|
||||||
"@babel/preset-typescript": "^7.17.12",
|
|
||||||
"@discordjs/scripts": "workspace:^",
|
"@discordjs/scripts": "workspace:^",
|
||||||
"@types/jest": "^28.1.0",
|
|
||||||
"@types/node": "^16.11.38",
|
"@types/node": "^16.11.38",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^5.27.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
||||||
"eslint": "^8.17.0",
|
"eslint": "^8.17.0",
|
||||||
"eslint-config-marine": "^9.4.1",
|
"eslint-config-marine": "^9.4.1",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"jest": "^28.1.0",
|
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"tsup": "^6.0.1",
|
"tsup": "^6.0.1",
|
||||||
"typedoc": "^0.22.17",
|
"typedoc": "^0.22.17",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import Collection from '../src';
|
import Collection from '../src';
|
||||||
|
|
||||||
type TestCollection = Collection<string, number>;
|
type TestCollection = Collection<string, number>;
|
||||||
@@ -247,7 +248,7 @@ test('random select from a collection', () => {
|
|||||||
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
const chars = 'abcdefghijklmnopqrstuvwxyz';
|
||||||
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26];
|
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26];
|
||||||
|
|
||||||
for (let i = 0; i < chars.length; i++) coll.set(chars[i], numbers[i]);
|
for (let i = 0; i < chars.length; i++) coll.set(chars[i]!, numbers[i]!);
|
||||||
|
|
||||||
const random = coll.random(5);
|
const random = coll.random(5);
|
||||||
expect(random.length === 5).toBeTruthy();
|
expect(random.length === 5).toBeTruthy();
|
||||||
@@ -357,7 +358,7 @@ describe('hasAny() tests', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('reverse() tests', () => {
|
test('reverse() tests', () => {
|
||||||
const coll = new Collection();
|
const coll = new Collection();
|
||||||
coll.set('a', 1);
|
coll.set('a', 1);
|
||||||
coll.set('b', 2);
|
coll.set('b', 2);
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@babel/core').TransformOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
parserOpts: { strictMode: true },
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
targets: { node: 'current' },
|
|
||||||
modules: 'commonjs',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'@babel/preset-typescript',
|
|
||||||
],
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@jest/types').Config.InitialOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
collectCoverage: true,
|
|
||||||
collectCoverageFrom: ['src/**/*.ts'],
|
|
||||||
coverageDirectory: 'coverage',
|
|
||||||
coverageReporters: ['text', 'lcov', 'clover'],
|
|
||||||
};
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
"version": "0.8.0-dev",
|
"version": "0.8.0-dev",
|
||||||
"description": "Utility data structure used in discord.js",
|
"description": "Utility data structure used in discord.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "jest --pass-with-no-tests",
|
|
||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
@@ -48,11 +47,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://discord.js.org",
|
"homepage": "https://discord.js.org",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
|
||||||
"@babel/preset-env": "^7.18.2",
|
|
||||||
"@babel/preset-typescript": "^7.17.12",
|
|
||||||
"@discordjs/scripts": "workspace:^",
|
"@discordjs/scripts": "workspace:^",
|
||||||
"@types/jest": "^28.1.0",
|
|
||||||
"@types/node": "^16.11.38",
|
"@types/node": "^16.11.38",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^5.27.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
@@ -60,7 +55,6 @@
|
|||||||
"eslint-config-marine": "^9.4.1",
|
"eslint-config-marine": "^9.4.1",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"jest": "^28.1.0",
|
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"tsup": "^6.0.1",
|
"tsup": "^6.0.1",
|
||||||
"typedoc": "^0.22.17",
|
"typedoc": "^0.22.17",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { REST } from '@discordjs/rest';
|
|||||||
import supertest from 'supertest';
|
import supertest from 'supertest';
|
||||||
import { MockAgent, Interceptable, setGlobalDispatcher } from 'undici';
|
import { MockAgent, Interceptable, setGlobalDispatcher } from 'undici';
|
||||||
import type { MockInterceptor } from 'undici/types/mock-interceptor';
|
import type { MockInterceptor } from 'undici/types/mock-interceptor';
|
||||||
|
import { beforeEach, afterAll, afterEach, test, expect } from 'vitest';
|
||||||
import { proxyRequests } from '../src';
|
import { proxyRequests } from '../src';
|
||||||
|
|
||||||
let mockAgent: MockAgent;
|
let mockAgent: MockAgent;
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@babel/core').TransformOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
parserOpts: { strictMode: true },
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
targets: { node: 'current' },
|
|
||||||
modules: 'commonjs',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'@babel/preset-typescript',
|
|
||||||
],
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@jest/types').Config.InitialOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
collectCoverage: true,
|
|
||||||
collectCoverageFrom: ['src/**/*.ts'],
|
|
||||||
coverageDirectory: 'coverage',
|
|
||||||
coverageReporters: ['text', 'lcov', 'clover'],
|
|
||||||
};
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
"description": "Tools for running an HTTP proxy for Discord's API",
|
"description": "Tools for running an HTTP proxy for Discord's API",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup && tsc --emitDeclarationOnly --incremental",
|
"build": "tsup && tsc --emitDeclarationOnly --incremental",
|
||||||
"test": "jest --pass-with-no-tests --collect-coverage",
|
|
||||||
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
|
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
|
||||||
@@ -57,23 +56,15 @@
|
|||||||
"undici": "^5.4.0"
|
"undici": "^5.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
|
||||||
"@babel/plugin-proposal-decorators": "^7.18.2",
|
|
||||||
"@babel/preset-env": "^7.18.2",
|
|
||||||
"@babel/preset-typescript": "^7.17.12",
|
|
||||||
"@discordjs/scripts": "workspace:^",
|
"@discordjs/scripts": "workspace:^",
|
||||||
"@types/jest": "^28.1.0",
|
|
||||||
"@types/node": "^16.11.38",
|
"@types/node": "^16.11.38",
|
||||||
"@types/supertest": "^2.0.12",
|
"@types/supertest": "^2.0.12",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^5.27.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
"babel-plugin-const-enum": "^1.2.0",
|
|
||||||
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
||||||
"eslint": "^8.17.0",
|
"eslint": "^8.17.0",
|
||||||
"eslint-config-marine": "^9.4.1",
|
"eslint-config-marine": "^9.4.1",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"jest": "^28.1.0",
|
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"supertest": "^6.2.3",
|
"supertest": "^6.2.3",
|
||||||
"tsup": "^6.0.1",
|
"tsup": "^6.0.1",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { test, expect } from 'vitest';
|
||||||
import { CDN } from '../src';
|
import { CDN } from '../src';
|
||||||
|
|
||||||
const base = 'https://discord.com';
|
const base = 'https://discord.com';
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { test, expect } from 'vitest';
|
||||||
import { DiscordAPIError } from '../src';
|
import { DiscordAPIError } from '../src';
|
||||||
|
|
||||||
test('Unauthorized', () => {
|
test('Unauthorized', () => {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { DiscordSnowflake } from '@sapphire/snowflake';
|
|||||||
import { Routes, Snowflake } from 'discord-api-types/v10';
|
import { Routes, Snowflake } from 'discord-api-types/v10';
|
||||||
import { File, FormData, MockAgent, setGlobalDispatcher } from 'undici';
|
import { File, FormData, MockAgent, setGlobalDispatcher } from 'undici';
|
||||||
import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor';
|
import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor';
|
||||||
|
import { beforeEach, afterEach, test, expect } from 'vitest';
|
||||||
import { genPath } from './util';
|
import { genPath } from './util';
|
||||||
import { REST } from '../src';
|
import { REST } from '../src';
|
||||||
|
|
||||||
@@ -107,7 +108,7 @@ test('simple POST', async () => {
|
|||||||
expect(await api.post('/simplePost')).toStrictEqual({ test: true });
|
expect(await api.post('/simplePost')).toStrictEqual({ test: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
test('simple PUT', async () => {
|
test('simple PUT 2', async () => {
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: genPath('/simplePut'),
|
path: genPath('/simplePut'),
|
||||||
@@ -285,7 +286,7 @@ test('Old Message Delete Edge-Case: Old message', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Old Message Delete Edge-Case: Old message', async () => {
|
test('Old Message Delete Edge-Case: Old message 2', async () => {
|
||||||
mockPool
|
mockPool
|
||||||
.intercept({
|
.intercept({
|
||||||
path: genPath(`/channels/339942739275677727/messages/${newSnowflake}`),
|
path: genPath(`/channels/339942739275677727/messages/${newSnowflake}`),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { performance } from 'node:perf_hooks';
|
import { performance } from 'node:perf_hooks';
|
||||||
import { MockAgent, setGlobalDispatcher } from 'undici';
|
import { MockAgent, setGlobalDispatcher } from 'undici';
|
||||||
import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor';
|
import type { Interceptable, MockInterceptor } from 'undici/types/mock-interceptor';
|
||||||
|
import { beforeEach, afterEach, test, expect, vitest } from 'vitest';
|
||||||
import { genPath } from './util';
|
import { genPath } from './util';
|
||||||
import { DiscordAPIError, HTTPError, RateLimitError, REST, RESTEvents } from '../src';
|
import { DiscordAPIError, HTTPError, RateLimitError, REST, RESTEvents } from '../src';
|
||||||
|
|
||||||
@@ -82,8 +83,8 @@ test('Significant Invalid Requests', async () => {
|
|||||||
.reply(403, { message: 'Missing Permissions', code: 50013 }, responseOptions)
|
.reply(403, { message: 'Missing Permissions', code: 50013 }, responseOptions)
|
||||||
.times(10);
|
.times(10);
|
||||||
|
|
||||||
const invalidListener = jest.fn();
|
const invalidListener = vitest.fn();
|
||||||
const invalidListener2 = jest.fn();
|
const invalidListener2 = vitest.fn();
|
||||||
api.on(RESTEvents.InvalidRequestWarning, invalidListener);
|
api.on(RESTEvents.InvalidRequestWarning, invalidListener);
|
||||||
// Ensure listeners on REST do not get double added
|
// Ensure listeners on REST do not get double added
|
||||||
api.on(RESTEvents.InvalidRequestWarning, invalidListener2);
|
api.on(RESTEvents.InvalidRequestWarning, invalidListener2);
|
||||||
@@ -364,6 +365,7 @@ test('Handle unexpected 429', async () => {
|
|||||||
expect(await unexepectedSublimit).toStrictEqual({ test: true });
|
expect(await unexepectedSublimit).toStrictEqual({ test: true });
|
||||||
expect(await queuedSublimit).toStrictEqual({ test: true });
|
expect(await queuedSublimit).toStrictEqual({ test: true });
|
||||||
expect(performance.now()).toBeGreaterThanOrEqual(previous + 1000);
|
expect(performance.now()).toBeGreaterThanOrEqual(previous + 1000);
|
||||||
|
// @ts-expect-error
|
||||||
expect(secondResolvedTime).toBeGreaterThan(firstResolvedTime);
|
expect(secondResolvedTime).toBeGreaterThan(firstResolvedTime);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -495,7 +497,7 @@ test('Unauthorized', async () => {
|
|||||||
.reply(401, { message: '401: Unauthorized', code: 0 }, responseOptions)
|
.reply(401, { message: '401: Unauthorized', code: 0 }, responseOptions)
|
||||||
.times(2);
|
.times(2);
|
||||||
|
|
||||||
const setTokenSpy = jest.spyOn(invalidAuthApi.requestManager, 'setToken');
|
const setTokenSpy = vitest.spyOn(invalidAuthApi.requestManager, 'setToken');
|
||||||
|
|
||||||
// Ensure authless requests don't reset the token
|
// Ensure authless requests don't reset the token
|
||||||
const promiseWithoutTokenClear = invalidAuthApi.get('/unauthorized', { auth: false });
|
const promiseWithoutTokenClear = invalidAuthApi.get('/unauthorized', { auth: false });
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { MockAgent, setGlobalDispatcher } from 'undici';
|
import { MockAgent, setGlobalDispatcher } from 'undici';
|
||||||
import { Interceptable } from 'undici/types/mock-interceptor';
|
import type { Interceptable } from 'undici/types/mock-interceptor';
|
||||||
|
import { beforeEach, afterEach, test, expect } from 'vitest';
|
||||||
import { genPath } from './util';
|
import { genPath } from './util';
|
||||||
import { REST } from '../src';
|
import { REST } from '../src';
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Blob } from 'node:buffer';
|
import { Blob } from 'node:buffer';
|
||||||
|
import { test, expect } from 'vitest';
|
||||||
import { resolveBody, parseHeader } from '../src/lib/utils/utils';
|
import { resolveBody, parseHeader } from '../src/lib/utils/utils';
|
||||||
|
|
||||||
test('GIVEN string parseHeader returns string', () => {
|
test('GIVEN string parseHeader returns string', () => {
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { describe, test, expect } from 'vitest';
|
||||||
import { makeURLSearchParams } from '../src';
|
import { makeURLSearchParams } from '../src';
|
||||||
|
|
||||||
describe('makeURLSearchParams', () => {
|
describe('makeURLSearchParams', () => {
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@babel/core').TransformOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
parserOpts: { strictMode: true },
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
targets: { node: 'current' },
|
|
||||||
modules: 'commonjs',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'@babel/preset-typescript',
|
|
||||||
],
|
|
||||||
plugins: [
|
|
||||||
['const-enum', { transform: 'constObject' }],
|
|
||||||
'babel-plugin-transform-typescript-metadata',
|
|
||||||
['@babel/plugin-proposal-decorators', { legacy: true }],
|
|
||||||
],
|
|
||||||
};
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@jest/types').Config.InitialOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
collectCoverage: true,
|
|
||||||
coverageProvider: 'v8',
|
|
||||||
coverageDirectory: 'coverage',
|
|
||||||
coverageReporters: ['html', 'text', 'clover'],
|
|
||||||
coverageThreshold: {
|
|
||||||
global: {
|
|
||||||
branches: 70,
|
|
||||||
lines: 70,
|
|
||||||
statements: 70,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
coveragePathIgnorePatterns: ['/node_modules/', '/__tests__/'],
|
|
||||||
};
|
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
"description": "The REST API for discord.js",
|
"description": "The REST API for discord.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup && tsc --emitDeclarationOnly --incremental",
|
"build": "tsup && tsc --emitDeclarationOnly --incremental",
|
||||||
"test": "jest --pass-with-no-tests --collect-coverage",
|
|
||||||
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
"lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
"format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
|
||||||
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
|
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && ts-docgen -i docs/typedoc-out.json -c docs/index.yml -o docs/docs.json",
|
||||||
@@ -58,21 +57,13 @@
|
|||||||
"undici": "^5.4.0"
|
"undici": "^5.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
|
||||||
"@babel/plugin-proposal-decorators": "^7.18.2",
|
|
||||||
"@babel/preset-env": "^7.18.2",
|
|
||||||
"@babel/preset-typescript": "^7.17.12",
|
|
||||||
"@discordjs/scripts": "workspace:^",
|
"@discordjs/scripts": "workspace:^",
|
||||||
"@types/jest": "^28.1.0",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^5.27.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
"babel-plugin-const-enum": "^1.2.0",
|
|
||||||
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
||||||
"eslint": "^8.17.0",
|
"eslint": "^8.17.0",
|
||||||
"eslint-config-marine": "^9.4.1",
|
"eslint-config-marine": "^9.4.1",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"jest": "^28.1.0",
|
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"tsup": "^6.0.1",
|
"tsup": "^6.0.1",
|
||||||
"typedoc": "^0.22.17",
|
"typedoc": "^0.22.17",
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@babel/core').TransformOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
parserOpts: { strictMode: true },
|
|
||||||
sourceMaps: 'inline',
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
targets: { node: 'current' },
|
|
||||||
modules: 'commonjs',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'@babel/preset-typescript',
|
|
||||||
],
|
|
||||||
plugins: ['babel-plugin-transform-typescript-metadata', ['@babel/plugin-proposal-decorators', { legacy: true }]],
|
|
||||||
};
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
* @type {import('@jest/types').Config.InitialOptions}
|
|
||||||
*/
|
|
||||||
module.exports = {
|
|
||||||
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
|
|
||||||
testEnvironment: 'node',
|
|
||||||
collectCoverage: true,
|
|
||||||
collectCoverageFrom: ['src/**/*.ts'],
|
|
||||||
coverageDirectory: 'coverage',
|
|
||||||
coverageReporters: ['text', 'lcov', 'clover'],
|
|
||||||
coverageThreshold: {
|
|
||||||
global: {
|
|
||||||
branches: 70,
|
|
||||||
lines: 70,
|
|
||||||
statements: 70,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
coveragePathIgnorePatterns: ['src/index.ts'],
|
|
||||||
};
|
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsup",
|
"build": "tsup",
|
||||||
"test": "jest --pass-with-no-tests",
|
|
||||||
"lint": "prettier --check . && eslint src --ext mjs,js,ts",
|
"lint": "prettier --check . && eslint src --ext mjs,js,ts",
|
||||||
"format": "prettier --write . && eslint src --ext mjs,js,ts --fix"
|
"format": "prettier --write . && eslint src --ext mjs,js,ts --fix"
|
||||||
},
|
},
|
||||||
@@ -51,20 +50,13 @@
|
|||||||
"tslib": "^2.4.0"
|
"tslib": "^2.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.2",
|
|
||||||
"@babel/plugin-proposal-decorators": "^7.18.2",
|
|
||||||
"@babel/preset-env": "^7.18.2",
|
|
||||||
"@babel/preset-typescript": "^7.17.12",
|
|
||||||
"@types/jest": "^28.1.0",
|
|
||||||
"@types/node": "^16.11.38",
|
"@types/node": "^16.11.38",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||||
"@typescript-eslint/parser": "^5.27.0",
|
"@typescript-eslint/parser": "^5.27.0",
|
||||||
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
||||||
"eslint": "^8.17.0",
|
"eslint": "^8.17.0",
|
||||||
"eslint-config-marine": "^9.4.1",
|
"eslint-config-marine": "^9.4.1",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"jest": "^28.1.0",
|
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"tsup": "^6.0.1",
|
"tsup": "^6.0.1",
|
||||||
"typescript": "^4.7.3"
|
"typescript": "^4.7.3"
|
||||||
|
|||||||
13
vitest.config.ts
Normal file
13
vitest.config.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { defineConfig } from 'vitest/config';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
test: {
|
||||||
|
exclude: ['node_modules', 'dist', '.idea', '.git', '.cache', 'packages/discord.js', 'packages/voice'],
|
||||||
|
passWithNoTests: true,
|
||||||
|
coverage: {
|
||||||
|
enabled: true,
|
||||||
|
reporter: ['text', 'lcov', 'clover'],
|
||||||
|
exclude: ['**/dist', '**/__tests__'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user