Skip to content

Commit 5136ca4

Browse files
authored
chore(tests): reenable unit tests in CI and cleanup docker test setups (#10190)
* fix: cleanup all docker-related tests * fix: reenable unit tests in release.yml GHA * fix: enable unstorage tests * fix: use container for firestore emulator * fix: cleanup working firestore tests * fix: move all db wait periods to 5s * fix: cleanup dgraph tests * fix: skip dgraph tests for now as theyre failing * fix: add typeorm to test blacklist and run prisma test without vitest watch mode * fix: cleanup prisma mongo test schema * fix: add prisma mongo env var back * fix: change to 'vitest run' in core test script * fix: a few adapters do take a bit longer to spin up * fix: temporarily disable prisma mongo tests
1 parent a973ead commit 5136ca4

File tree

46 files changed

+534
-1836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+534
-1836
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,8 @@ jobs:
9191
- name: Build
9292
run: pnpm build
9393
- name: Run unit tests
94-
if: false
9594
run: pnpm test
9695
timeout-minutes: 15
97-
env:
98-
UPSTASH_REDIS_URL: ${{ secrets.UPSTASH_REDIS_URL }}
99-
UPSTASH_REDIS_KEY: ${{ secrets.UPSTASH_REDIS_KEY }}
10096
- name: Get installed Playwright version
10197
id: playwright-version
10298
run: echo "PLAYWRIGHT_VERSION=$(pnpx playwright -V | awk '{ print $2 }')" >> $GITHUB_ENV

apps/examples/nextjs-docker/test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ if ! docker-compose "${args[@]}"; then
1616
exit 1
1717
fi
1818

19-
echo "waiting 10 seconds for container to start..."
20-
sleep 10
19+
echo "waiting 5s for container to start..."
20+
sleep 5
2121

2222
# Used to control which env vars to load in the playwright process
2323
export TEST_DOCKER=1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"build:app": "turbo run build --filter=next-auth-app",
88
"build:docs": "turbo run build --filter=docs",
99
"build": "turbo run build --filter=next-auth --filter=@auth/* --no-deps",
10-
"test": "turbo run test --concurrency=1 --filter=[HEAD^1] --filter=./packages/* --filter=!*app* --filter=!*dynamo* --filter=!*edgedb* --filter=!*hasura* --filter=!*mikro* --filter=!*supabase* --filter=!*upstash* --filter=!*xata*",
10+
"test": "turbo run test --concurrency=1 --filter=[HEAD^1] --filter=./packages/* --filter=!*app* --filter=!*dynamo* --filter=!*edgedb* --filter=!*hasura* --filter=!*mikro* --filter=!*supabase* --filter=!*dgraph* --filter=!*xata* --filter=!*typeorm*",
1111
"test:e2e": "turbo run test:e2e",
1212
"test:e2e:watch": "turbo run test:e2e -- --ui",
1313
"clean": "turbo run clean --no-cache",

packages/adapter-azure-tables/test/test.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
CONTAINER_NAME=authjs-azure-tables-test
44

55
# Start db
6-
docker run -d -p 10002:10002 --name ${CONTAINER_NAME} mcr.microsoft.com/azure-storage/azurite azurite-table -l /workspace -d /workspace/debug.log --tableHost 0.0.0.0 --loose
6+
docker run -d --rm \
7+
-p 10002:10002 \
8+
--name ${CONTAINER_NAME} \
9+
mcr.microsoft.com/azure-storage/azurite azurite-table -l /workspace -d /workspace/debug.log --tableHost 0.0.0.0 --loose
710

8-
echo "Waiting 3 sec for db to start..."
9-
sleep 3
11+
echo "Waiting 10s for db to start..."
12+
sleep 10
1013

1114
# Always stop container, but exit with 1 when tests are failing
12-
if vitest -c ../utils/vitest.config.ts;then
13-
docker stop ${CONTAINER_NAME}
15+
if vitest run -c ../utils/vitest.config.ts; then
16+
docker stop ${CONTAINER_NAME}
1417
else
15-
docker stop ${CONTAINER_NAME} && exit 1
18+
docker stop ${CONTAINER_NAME} && exit 1
1619
fi

packages/adapter-dgraph/src/lib/client.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ export class DgraphClientError extends Error {
3434

3535
export function client(params: DgraphClientParams) {
3636
if (!params.authToken) {
37-
throw new Error("Dgraph client error: Please provide an api key")
37+
throw new Error("Dgraph client error: Please provide an API key")
3838
}
3939
if (!params.endpoint) {
40-
throw new Error("Dgraph client error: Please provide a graphql endpoint")
40+
throw new Error(
41+
"Dgraph client error: Please provide a valid GraphQL endpoint"
42+
)
4143
}
4244

4345
const {

packages/adapter-dgraph/src/lib/graphql/schema.gql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type User
3838
or: [
3939
{
4040
rule: """
41-
query ($userId: String!) {queryUser(filter: { id: { eq: $userId } } ) {id}}
41+
query ($userId: ID!) {queryUser(filter: { id: [$userId] } ) {id}}
4242
"""
4343
}
4444
{ rule: "{$nextAuth: { eq: true } }" }
@@ -50,7 +50,7 @@ type User
5050
or: [
5151
{
5252
rule: """
53-
query ($userId: String!) {queryUser(filter: { id: { eq: $userId } } ) {id}}
53+
query ($userId: ID!) {queryUser(filter: { id: [$userId] } ) {id}}
5454
"""
5555
}
5656
{ rule: "{$nextAuth: { eq: true } }" }

packages/adapter-dgraph/test/test.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,27 @@
33
CONTAINER_NAME=authjs-dgraph
44

55
# Start db
6-
76
docker run -d --rm \
8-
-p 8000:8000 -p 8080:8080 \
9-
--name "${CONTAINER_NAME}" \
10-
dgraph/standalone
7+
-p 8080:8080 \
8+
-p 9080:9080 \
9+
--name "${CONTAINER_NAME}" \
10+
dgraph/standalone:latest
1111

12-
echo "Waiting 15 sec for db to start..." && sleep 15
12+
echo "Waiting 15s for db to start..." && sleep 15
1313

14-
head -n -1 src/lib/graphql/schema.gql > test/test.schema.gql
14+
head -n -1 src/lib/graphql/schema.gql >test/test.schema.gql
1515
PUBLIC_KEY=$(sed 's/$/\\n/' test/public.key | tr -d '\n')
16-
echo "# Dgraph.Authorization {\"VerificationKey\":\"$PUBLIC_KEY\",\"Namespace\":\"https://dgraph.io/jwt/claims\",\"Header\":\"Authorization\",\"Algo\":\"RS256\"}" >> test/test.schema.gql
16+
echo "# Dgraph.Authorization {\"VerificationKey\":\"$PUBLIC_KEY\",\"Namespace\":\"https://dgraph.io/jwt/claims\",\"Header\":\"Authorization\",\"Algo\":\"RS256\"}" >>test/test.schema.gql
1717

1818
curl -X POST localhost:8080/admin/schema --data-binary '@test/test.schema.gql'
1919

20-
printf "\nWaiting 5 sec for schema to be uploaded..." && sleep 5
21-
20+
printf "\nWaiting 5s for schema to be uploaded..." && sleep 5
2221

2322
# Always stop container, but exit with 1 when tests are failing
24-
if vitest -c ../utils/vitest.config.ts; then
25-
docker stop "${CONTAINER_NAME}"
23+
if vitest run -c ../utils/vitest.config.ts; then
24+
docker stop "${CONTAINER_NAME}"
2625
else
27-
docker stop "${CONTAINER_NAME}"
26+
docker stop "${CONTAINER_NAME}" && exit 1
2827
fi
2928

30-
rm test/test.schema.gql
29+
rm test/test.schema.gql

packages/adapter-drizzle/test/mysql-multi-project-schema/test.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ MYSQL_ROOT_PASSWORD=password
77
MYSQL_CONTAINER_NAME=next-auth-mysql-test
88

99
docker run -d --rm \
10-
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
11-
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
12-
--name "${MYSQL_CONTAINER_NAME}" \
13-
-p 3306:3306 \
14-
mysql:8 \
15-
--default-authentication-plugin=mysql_native_password
10+
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
11+
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
12+
--name "${MYSQL_CONTAINER_NAME}" \
13+
-p 3306:3306 \
14+
mysql:8 \
15+
--default-authentication-plugin=mysql_native_password
1616

17-
echo "Waiting 15 sec for db to start..." && sleep 15
17+
echo "Waiting 5s for db to start..." && sleep 5
1818

19+
# Push schema and seed
1920
NODE_OPTIONS='--import tsx' drizzle-kit generate:mysql --config=./test/mysql/drizzle.config.ts
2021
NODE_OPTIONS='--import tsx' drizzle-kit push:mysql --config=./test/mysql/drizzle.config.ts
21-
vitest -c ../utils/vitest.config.ts ./test/mysql/index.test.ts
22-
docker stop ${MYSQL_CONTAINER_NAME}
22+
23+
if vitest run -c ../utils/vitest.config.ts ./test/mysql/index.test.ts; then
24+
docker stop ${MYSQL_CONTAINER_NAME}
25+
else
26+
docker stop ${MYSQL_CONTAINER_NAME} && exit 1
27+
fi

packages/adapter-drizzle/test/mysql/test.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@ MYSQL_ROOT_PASSWORD=password
77
MYSQL_CONTAINER_NAME=next-auth-mysql-test
88

99
docker run -d --rm \
10-
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
11-
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
12-
--name "${MYSQL_CONTAINER_NAME}" \
13-
-p 3306:3306 \
14-
mysql:8 \
15-
--default-authentication-plugin=mysql_native_password
10+
-e MYSQL_DATABASE=${MYSQL_DATABASE} \
11+
-e MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \
12+
--name "${MYSQL_CONTAINER_NAME}" \
13+
-p 3306:3306 \
14+
mysql:8 \
15+
--default-authentication-plugin=mysql_native_password
1616

17-
echo "Waiting 15 sec for db to start..." && sleep 15
17+
echo "Waiting 10s for db to start..." && sleep 10
1818

19+
# Push schema and seed
1920
NODE_OPTIONS='--import tsx' drizzle-kit generate:mysql --config=./test/mysql/drizzle.config.ts
2021
NODE_OPTIONS='--import tsx' drizzle-kit push:mysql --config=./test/mysql/drizzle.config.ts
21-
vitest -c ../utils/vitest.config.ts ./test/mysql/index.test.ts
22-
docker stop ${MYSQL_CONTAINER_NAME}
22+
23+
if vitest run -c ../utils/vitest.config.ts ./test/mysql/index.test.ts; then
24+
docker stop ${MYSQL_CONTAINER_NAME}
25+
else
26+
docker stop ${MYSQL_CONTAINER_NAME} && exit 1
27+
fi

packages/adapter-drizzle/test/pg-multi-project-schema/test.sh

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ PGPORT=5432
99
PG_CONTAINER_NAME=next-auth-postgres-test
1010

1111
docker run -d --rm \
12-
-e POSTGRES_USER=${PGUSER} \
13-
-e POSTGRES_PASSWORD=${PGUSER} \
14-
-e POSTGRES_DB=${PGDATABASE} \
15-
-e POSTGRES_HOST_AUTH_METHOD=trust \
16-
--name "${PG_CONTAINER_NAME}" \
17-
-p ${PGPORT}:5432 \
18-
postgres:15.3
12+
-e POSTGRES_USER=${PGUSER} \
13+
-e POSTGRES_PASSWORD=${PGPASSWORD} \
14+
-e POSTGRES_DB=${PGDATABASE} \
15+
-e POSTGRES_HOST_AUTH_METHOD=trust \
16+
--name "${PG_CONTAINER_NAME}" \
17+
-p ${PGPORT}:5432 \
18+
postgres:15.3
1919

20-
echo "Waiting 15 sec for db to start..." && sleep 15
20+
echo "Waiting 5s for db to start..." && sleep 5
2121

22+
# Push schema and seed
2223
drizzle-kit generate:pg --config=./test/pg/drizzle.config.ts
2324
tsx ./test/pg/migrator.ts
24-
vitest -c ../utils/vitest.config.ts ./test/pg/index.test.ts
25-
docker stop ${PG_CONTAINER_NAME}
25+
26+
if vitest run -c ../utils/vitest.config.ts ./test/pg/index.test.ts; then
27+
docker stop ${PG_CONTAINER_NAME}
28+
else
29+
docker stop ${PG_CONTAINER_NAME} && exit 1
30+
fi

0 commit comments

Comments
 (0)