From 89d9d9afd6edf58055e7e597ddafdae3122c6dfd Mon Sep 17 00:00:00 2001 From: Nicholas Cunningham Date: Wed, 1 Jun 2022 12:36:54 -0600 Subject: [PATCH] fix(nextjs): update e2e test case to cover env variables exported from libraries (#10532) ISSUES CLOSED: #9633 update Co-authored-by: Nicholas Cunningham --- e2e/next/src/next.test.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/e2e/next/src/next.test.ts b/e2e/next/src/next.test.ts index ac0f8a30380b8..9f97b6db2d191 100644 --- a/e2e/next/src/next.test.ts +++ b/e2e/next/src/next.test.ts @@ -144,9 +144,12 @@ describe('Next.js Applications', () => { it('should be able to serve with a proxy configuration', async () => { const appName = uniq('app'); + const jsLib = uniq('tslib'); + const port = 4201; runCLI(`generate @nrwl/next:app ${appName}`); + runCLI(`generate @nrwl/js:lib ${jsLib} --no-interactive`); const proxyConf = { '/external-api': { @@ -159,14 +162,24 @@ describe('Next.js Applications', () => { updateFile(`apps/${appName}/proxy.conf.json`, JSON.stringify(proxyConf)); updateFile('.env.local', 'NX_CUSTOM_VAR=test value from a file'); + updateFile( + `libs/${jsLib}/src/lib/${jsLib}.ts`, + ` + export function testFn(): string { + return process.env.NX_CUSTOM_VAR; + }; + ` + ); + updateFile( `apps/${appName}/pages/index.tsx`, ` import React from 'react'; + import { testFn } from '@${proj}/${jsLib}'; export const Index = ({ greeting }: any) => { return ( -

{process.env.NX_CUSTOM_VAR}

+

{testFn()}

); }; export default Index;