Skip to content

Commit

Permalink
tests: adapt for ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Feb 25, 2024
1 parent 7923950 commit 12b8a00
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 15 deletions.
11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "prettier --check '{src,test,scripts}/**/*' README.md package.json",
"lint:fix": "prettier --write '{src,test,scripts}/**/*' README.md package.json",
"pretest": "npm run -s lint",
"test": "jest --coverage"
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage"
},
"repository": "https://github.com/octokit/oauth-methods.js",
"keywords": [
Expand Down Expand Up @@ -41,11 +41,15 @@
"typescript": "^5.0.0"
},
"jest": {
"extensionsToTreatAsEsm": [
".ts"
],
"transform": {
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
"tsconfig": "test/tsconfig.test.json"
"tsconfig": "test/tsconfig.test.json",
"useESM": true
}
]
},
Expand All @@ -56,6 +60,9 @@
"functions": 100,
"lines": 100
}
},
"moduleNameMapper": {
"^(.+)\\.jsx?$": "$1"
}
},
"release": {
Expand Down
2 changes: 1 addition & 1 deletion test/check-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { checkToken } from "../src";
import { checkToken } from "../src/index.js";

describe("checkToken()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/create-device-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { createDeviceCode } from "../src";
import { createDeviceCode } from "../src/index.js";

describe("createDeviceCode()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/delete-authorization.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { deleteAuthorization } from "../src";
import { deleteAuthorization } from "../src/index.js";

describe("deleteAuthorization()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/delete-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { deleteToken } from "../src";
import { deleteToken } from "../src/index.js";

describe("deleteToken()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/exchange-device-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { exchangeDeviceCode } from "../src";
import { exchangeDeviceCode } from "../src/index.js";

describe("exchangeDeviceCode()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/exchange-web-flow-code.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { exchangeWebFlowCode } from "../src";
import { exchangeWebFlowCode } from "../src/index.js";

describe("exchangeWebFlowCode()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/get-web-flow-authorization-url.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { request } from "@octokit/request";
import { getWebFlowAuthorizationUrl } from "../src";
import { getWebFlowAuthorizationUrl } from "../src/index.js";

describe("getWebFlowAuthorizationUrl()", () => {
it("README example", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/refresh-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { refreshToken } from "../src";
import { refreshToken } from "../src/index.js";

describe("refreshToken()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/reset-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { resetToken } from "../src";
import { resetToken } from "../src/index.js";

describe("resetToken()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/scope-token.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
import { request } from "@octokit/request";
import { scopeToken } from "../src";
import { scopeToken } from "../src/index.js";

describe("scopeToken()", () => {
it("README example", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
deleteToken,
deleteAuthorization,
VERSION,
} from "../src";
} from "../src/index.js";

describe("Smoke test", () => {
it("exports getWebFlowAuthorizationUrl", () => {
Expand Down
3 changes: 1 addition & 2 deletions test/tsconfig.test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": false,
"noEmit": true,
"verbatimModuleSyntax": false
"noEmit": true
},
"include": ["src/**/*"]
}

0 comments on commit 12b8a00

Please sign in to comment.