Skip to content

Commit

Permalink
Allow importing modules with aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelnietoa committed Jan 24, 2022
1 parent 6fcf6be commit 6808ab8
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/prisma.ts
@@ -1,6 +1,6 @@
import { PrismaClient } from "@prisma/client";

import { IS_PRODUCTION } from "./config/constants";
import { IS_PRODUCTION } from "@lib/config/constants";

declare global {
// eslint-disable-next-line no-var
Expand Down
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -114,6 +114,7 @@
"@types/jest": "^27.0.3",
"@types/lodash": "^4.14.177",
"@types/micro": "^7.3.6",
"@types/module-alias": "^2.0.1",
"@types/node": "^16.11.10",
"@types/nodemailer": "^6.4.4",
"@types/qrcode": "^1.4.1",
Expand All @@ -138,6 +139,7 @@
"jest": "^26.0.0",
"lint-staged": "^11.1.2",
"mockdate": "^3.0.5",
"module-alias": "^2.2.2",
"npm-run-all": "^4.1.5",
"postcss": "^8.4.4",
"prettier": "^2.3.2",
Expand Down
13 changes: 13 additions & 0 deletions playwright.config.ts
@@ -1,4 +1,17 @@
import { PlaywrightTestConfig, devices } from "@playwright/test";
import { addAliases } from "module-alias";

// Add aliases for the paths specified in the tsconfig.json file.
// This is needed because playwright does not consider tsconfig.json
// For more info, see:
// https://stackoverflow.com/questions/69023682/typescript-playwright-error-cannot-find-module
// https://github.com/microsoft/playwright/issues/7066#issuecomment-983984496
addAliases({
"@components": __dirname + "/components",
"@lib": __dirname + "/lib",
"@server": __dirname + "/server",
"@ee": __dirname + "/ee",
});

const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
Expand Down
5 changes: 3 additions & 2 deletions playwright/auth/auth-index.test.ts
@@ -1,7 +1,8 @@
import { expect, test } from "@playwright/test";

import { BASE_URL } from "../../lib/config/constants";
import prisma from "../../lib/prisma";
import { BASE_URL } from "@lib/config/constants";
import prisma from "@lib/prisma";

import { todo } from "../lib/testUtils";

test.describe("Can signup from a team invite", async () => {
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Expand Up @@ -2546,6 +2546,11 @@
"@types/node" "*"
"@types/socket.io" "2.1.13"

"@types/module-alias@^2.0.1":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/module-alias/-/module-alias-2.0.1.tgz#e5893236ce922152d57c5f3f978f764f4deeb45f"
integrity sha512-DN/CCT1HQG6HquBNJdLkvV+4v5l/oEuwOHUPLxI+Eub0NED+lk0YUfba04WGH90EINiUrNgClkNnwGmbICeWMQ==

"@types/node@*", "@types/node@>=8.1.0":
version "16.11.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
Expand Down Expand Up @@ -7493,6 +7498,11 @@ mockdate@^3.0.5:
resolved "https://registry.yarnpkg.com/mockdate/-/mockdate-3.0.5.tgz#789be686deb3149e7df2b663d2bc4392bc3284fb"
integrity sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ==

module-alias@^2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/module-alias/-/module-alias-2.2.2.tgz#151cdcecc24e25739ff0aa6e51e1c5716974c0e0"
integrity sha512-A/78XjoX2EmNvppVWEhM2oGk3x4lLxnkEA4jTbaK97QKSDjkIoOsKQlfylt/d3kKKi596Qy3NP5XrXJ6fZIC9Q==

mongodb-connection-string-url@^2.3.2:
version "2.4.1"
resolved "https://registry.yarnpkg.com/mongodb-connection-string-url/-/mongodb-connection-string-url-2.4.1.tgz#6b3c6c40133a0ad059fe9a0abda64b2a1cb4e8b4"
Expand Down

0 comments on commit 6808ab8

Please sign in to comment.