From b865d90a6d4cb54de3a186f6839a88290e4085bd Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Mills Date: Mon, 21 Aug 2023 16:47:06 -1000 Subject: [PATCH 1/5] fix(bundlers): adapt webpack browser test --- bundlers/webpack-browser-custom-output/index.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bundlers/webpack-browser-custom-output/index.test.js b/bundlers/webpack-browser-custom-output/index.test.js index c920cfd6412f..124eba406282 100644 --- a/bundlers/webpack-browser-custom-output/index.test.js +++ b/bundlers/webpack-browser-custom-output/index.test.js @@ -1,5 +1,9 @@ const { PrismaClient } = require('./dist/prismaTest') -test('correctly generates browser bundle for prisma at custom path', () => { - expect(() => new PrismaClient()).toThrow('PrismaClient is unable to be run in the browser') +test('correctly generates browser bundle for prisma at custom path', async () => { + await expect(new PrismaClient().user.findFirst()).rejects.toThrow( + expect.objectContaining({ + message: expect.stringContaining('PrismaClient is unable to run in'), + }), + ) }) From f11fbe35b06d2ecc91466d3834487883a4ac4b33 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Mills Date: Mon, 21 Aug 2023 16:52:49 -1000 Subject: [PATCH 2/5] update --- bundlers/webpack-browser-custom-output/index.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundlers/webpack-browser-custom-output/index.test.js b/bundlers/webpack-browser-custom-output/index.test.js index 124eba406282..cf6d013ed8ec 100644 --- a/bundlers/webpack-browser-custom-output/index.test.js +++ b/bundlers/webpack-browser-custom-output/index.test.js @@ -1,7 +1,7 @@ const { PrismaClient } = require('./dist/prismaTest') test('correctly generates browser bundle for prisma at custom path', async () => { - await expect(new PrismaClient().user.findFirst()).rejects.toThrow( + expect(new PrismaClient().user.findFirst()).toThrow( expect.objectContaining({ message: expect.stringContaining('PrismaClient is unable to run in'), }), From 0b6e3a858249f6463f65958a3387dc8d52eecf1c Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Mills Date: Mon, 21 Aug 2023 16:57:05 -1000 Subject: [PATCH 3/5] fix test --- bundlers/webpack-browser-custom-output/index.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bundlers/webpack-browser-custom-output/index.test.js b/bundlers/webpack-browser-custom-output/index.test.js index cf6d013ed8ec..ba5c5faf9801 100644 --- a/bundlers/webpack-browser-custom-output/index.test.js +++ b/bundlers/webpack-browser-custom-output/index.test.js @@ -1,9 +1,9 @@ const { PrismaClient } = require('./dist/prismaTest') test('correctly generates browser bundle for prisma at custom path', async () => { - expect(new PrismaClient().user.findFirst()).toThrow( - expect.objectContaining({ - message: expect.stringContaining('PrismaClient is unable to run in'), - }), - ) + try { + await new PrismaClient().user.findFirst() + } catch (e) { + expect(e.message).toContain('PrismaClient is unable to run in') + } }) From 645fea01e4e504b9bc04ef3c2e6025a49a5cfa88 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Mills Date: Mon, 21 Aug 2023 16:57:22 -1000 Subject: [PATCH 4/5] add assertion count --- bundlers/webpack-browser-custom-output/index.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bundlers/webpack-browser-custom-output/index.test.js b/bundlers/webpack-browser-custom-output/index.test.js index ba5c5faf9801..80c6580685bd 100644 --- a/bundlers/webpack-browser-custom-output/index.test.js +++ b/bundlers/webpack-browser-custom-output/index.test.js @@ -1,6 +1,8 @@ const { PrismaClient } = require('./dist/prismaTest') test('correctly generates browser bundle for prisma at custom path', async () => { + expect.assertions(1) + try { await new PrismaClient().user.findFirst() } catch (e) { From c125427ff81e44e62319f56a76adabd2c8eb7f6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joe=CC=88l=20Galeran?= Date: Tue, 22 Aug 2023 11:20:37 +0200 Subject: [PATCH 5/5] add more tests --- .../index.test.js | 37 +++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/bundlers/webpack-browser-custom-output/index.test.js b/bundlers/webpack-browser-custom-output/index.test.js index 80c6580685bd..e7098bea10d5 100644 --- a/bundlers/webpack-browser-custom-output/index.test.js +++ b/bundlers/webpack-browser-custom-output/index.test.js @@ -1,11 +1,34 @@ const { PrismaClient } = require('./dist/prismaTest') +const prisma = new PrismaClient() -test('correctly generates browser bundle for prisma at custom path', async () => { - expect.assertions(1) +describe('Using browser custom output', () => { + test('prisma.user.findFirst() should fail', async () => { + expect.assertions(1) - try { - await new PrismaClient().user.findFirst() - } catch (e) { - expect(e.message).toContain('PrismaClient is unable to run in') - } + try { + prisma.user.findFirst() + } catch (e) { + expect(e.message).toContain('PrismaClient is unable to run in') + } + }) + + test('prisma.queryRaw`...` should fail', async () => { + expect.assertions(1) + + try { + prisma.$queryRaw`SELECT 1` + } catch (e) { + expect(e.message).toContain('PrismaClient is unable to run in') + } + }) + + test('When using a client extension it should fail', async () => { + expect.assertions(1) + + try { + prisma.$extends({}) + } catch (e) { + expect(e.message).toContain('PrismaClient is unable to run in') + } + }) })