Skip to content

Commit

Permalink
Jest tests now support ES Modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Konard committed May 29, 2023
1 parent 5bd7e11 commit 6f2503d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 5 additions & 1 deletion integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createRequire } from 'module';
import { jest } from '@jest/globals';
const require = createRequire(import.meta.url);

require('dotenv').config();

jest.setTimeout(1000000);
jest.setTimeout(120000);

// Please move slowest tests to bottom to make progress bar more dynamic and get more tests done first.

Expand Down
4 changes: 0 additions & 4 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
export default {
preset: 'ts-jest',
testEnvironment: 'node',
// testEnvironmentOptions: {
// url: "http://localhost/",
// },
verbose: true,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"package:build": "tsc --project tsconfig.json",
"package:unbuild": "rimraf ./*.js && rimraf ./*.js.map && rimraf ./*.d.ts && (cd ./migrations && rimraf ./*.js && rimraf ./*.js.map && rimraf ./*.d.ts && cd ../) && (cd ./imports && rimraf ./*.js && rimraf ./*.js.map && rimraf ./*.d.ts && cd ../) && (cd ./imports/gql && rimraf ./*.js && rimraf ./*.js.map && rimraf ./*.d.ts && cd ../..) && (cd ./benchmarks && rm -f ./*.js; rm -f ./*.js.map; rm -f ./*.d.ts && cd ..) && (cd ./imports/router && rimraf ./*.js && rimraf ./*.js.map && rimraf ./*.d.ts && cd ../..) && (cd ./tests && rimraf ./*.js && rimraf ./*.js.map && rimraf ./*.d.ts && cd ../)",
"package:publish": "npm run package:build && npm publish --access public && npm run package:unbuild",
"test": "cross-env DEEPLINKS_HASURA_PATH=localhost:8080 DEEPLINKS_HASURA_SSL=0 DEEPLINKS_HASURA_SECRET=myadminsecretkey DOCKER_DEEPLINKS_URL=http://localhost:3006 jest --testTimeout=50000",
"test": "npm run package:build && cross-env DEEPLINKS_HASURA_PATH=localhost:8080 DEEPLINKS_HASURA_SSL=0 DEEPLINKS_HASURA_SECRET=myadminsecretkey DOCKER_DEEPLINKS_URL=http://localhost:3006 NODE_OPTIONS=--experimental-vm-modules jest --config jest.config.js *.js --testTimeout=50000",
"benchmark": "export DEEPLINKS_HASURA_PATH=localhost:8080; export DEEPLINKS_HASURA_SSL=0; export DEEPLINKS_HASURA_SECRET=myadminsecretkey; ts-node benchmarks/index.ts",
"migrate": "npm run package:build && cp migrations/*.js migrations-dist/ && npx migrate up --migrations-dir migrations-dist",
"unmigrate": "npm run package:build && cp migrations/*.js migrations-dist/ && npx migrate down --migrations-dir migrations-dist",
Expand Down
2 changes: 0 additions & 2 deletions tests/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ Debug.enable(`${namespaces ? `${namespaces},` : ``}${error.namespace}`);
import waitOn from 'wait-on';
import getPort from 'get-port';

jest.setTimeout(120000);

export const api = new HasuraApi({
path: process.env.DEEPLINKS_HASURA_PATH,
ssl: !!+process.env.DEEPLINKS_HASURA_SSL,
Expand Down
2 changes: 0 additions & 2 deletions tests/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { insertHandler, deleteHandler } from "../imports/handlers";
import { _ids } from '../imports/client.js';
import { delay } from "../imports/promise";

jest.setTimeout(120000);

export const api = new HasuraApi({
path: process.env.DEEPLINKS_HASURA_PATH,
ssl: !!+process.env.DEEPLINKS_HASURA_SSL,
Expand Down
6 changes: 5 additions & 1 deletion unit.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createRequire } from 'module';
import { jest } from '@jest/globals';
const require = createRequire(import.meta.url);

require('dotenv').config();

jest.setTimeout(1000000);
jest.setTimeout(120000);

import './tests/minilinks';
import './tests/minilinks-query';

0 comments on commit 6f2503d

Please sign in to comment.