Skip to content

Commit

Permalink
fix(nextjs): update e2e test case to cover env variables exported fro…
Browse files Browse the repository at this point in the history
…m libraries (#10532)

ISSUES CLOSED: #9633

update

Co-authored-by: Nicholas Cunningham <ndcunningham>
  • Loading branch information
ndcunningham committed Jun 1, 2022
1 parent 210edd7 commit 89d9d9a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion e2e/next/src/next.test.ts
Expand Up @@ -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': {
Expand All @@ -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 (
<p>{process.env.NX_CUSTOM_VAR}</p>
<p>{testFn()}</p>
);
};
export default Index;
Expand Down

0 comments on commit 89d9d9a

Please sign in to comment.