Skip to content

Commit c4d21fe

Browse files
committed
testing that works maybe
1 parent 5c1cdcd commit c4d21fe

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

__tests__/pause-client.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
import { expect, jest, test, describe } from '@jest/globals';
2+
3+
import * as HttpClient from '@actions/http-client';
4+
15
import { PAUSEClient } from '~/pause-client';
26

37
describe('normal', () => {
4-
it('downloadUrl', async () => {
8+
test('downloadUrl', async () => {
9+
jest.mock('@actions/http-client', () => ({
10+
...HttpClient,
11+
"HttpClient": jest.fn().mockImplementation(() => ({
12+
post: jest.fn(),
13+
})),
14+
}));
15+
16+
const { PAUSEClient } = await import('~/pause-client');
17+
518
const client = new PAUSEClient('HAARG', 'my-password');
619

7-
client.uploadUrl = 'http://localhost:5555/';
20+
// client.uploadUrl = 'http://localhost:5555/';
821

9-
console.log(client);
1022
/*
1123
const upload = await client.upload({
1224
file: './README.md',

jest.config.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { pathsToModuleNameMapper } from 'ts-jest';
33
import { compilerOptions } from './tsconfig.json';
44

55
const config: Config.InitialOptions = {
6-
preset: 'ts-jest/presets/default-esm',
76
testEnvironment: 'node',
87
verbose: true,
98
testMatch: ['**/__tests__/*.test.ts'],
@@ -12,5 +11,17 @@ const config: Config.InitialOptions = {
1211
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
1312
prefix: '<rootDir>/',
1413
}),
14+
transform: {
15+
"^.+\\.m?tsx?$": [
16+
'ts-jest',
17+
{
18+
useESM: true,
19+
tsconfig: {
20+
...compilerOptions,
21+
allowImportingTsExtensions: true,
22+
},
23+
},
24+
],
25+
},
1526
};
1627
export default config;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"build": "tsc",
99
"lint": "eslint .",
1010
"lint:fix": "eslint --fix .",
11-
"test": "jest",
12-
"package": "tsc && ncc build lib/main.js"
11+
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings=ExperimentalWarning' jest",
12+
"package": "tsc && ncc build --license licenses.txt",
1313
"license-check": "license-checker --production --onlyAllow \"Apache-2.0;BSD-2-Clause;BSD-3-Clause;ISC;MIT;CC0-1.0;Unlicense\" --summary"
1414
},
1515
"keywords": [],

src/pause-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { HttpClient, type HttpClientResponse } from '@actions/http-client';
2-
import { BasicCredentialHandler } from '@actions/http-client/auth';
2+
import { BasicCredentialHandler } from '@actions/http-client/lib/auth';
33
import FormData from 'form-data';
44
import { type OutgoingHttpHeaders } from 'http';
55
import { readFile } from 'node:fs/promises';

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"declaration": true,
66
"sourceMap": true,
77
"target": "es2019",
8-
"module": "es2015",
8+
"module": "es2020",
99
"moduleResolution": "node16",
1010
"types": ["node", "jest"],
1111
"strict": true,

0 commit comments

Comments
 (0)