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

ISSUES CLOSED: #9633

update
  • Loading branch information
Nicholas Cunningham committed Jun 1, 2022
1 parent 6793e14 commit c206847
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion e2e/next/src/next.test.ts
Original file line number Diff line number Diff line change
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>
<>{JSON.stringify(testFn())}</>
);
};
export default Index;
Expand Down

0 comments on commit c206847

Please sign in to comment.