Skip to content

Commit

Permalink
Removed duplicated tests in the e2e suite
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPshul committed Jun 9, 2024
1 parent 508e55c commit cc0831f
Showing 1 changed file with 3 additions and 58 deletions.
61 changes: 3 additions & 58 deletions e2e/func-e2e/tests/func.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { NxJsonConfiguration } from '@nx/devkit';
import { ensureNxProject, readJson, runCommand, runNxCommandAsync, uniq, updateFile } from '@nx/plugin/testing';
import { CompilerOptions } from 'typescript';

describe('Project initialization and build', () => {
const TEST_TIMEOUT = 180000;
Expand All @@ -11,7 +10,9 @@ describe('Project initialization and build', () => {
// on a unique project in the workspace, such that they
// are not dependant on one another.
beforeAll(() => {
console.log('Before all');
ensureNxProject('@nxazure/func', 'dist/packages/func');
console.log('After ensureNxProject');

const nxConfig = readJson<NxJsonConfiguration>('nx.json');
nxConfig.workspaceLayout = {
Expand All @@ -21,6 +22,7 @@ describe('Project initialization and build', () => {

updateFile('nx.json', JSON.stringify(nxConfig, null, 2));

console.log('Installing types');
runCommand('npm i @types/node@latest', {});
});

Expand All @@ -30,33 +32,6 @@ describe('Project initialization and build', () => {
runNxCommandAsync('reset');
});

it(
'should init & build an empty workspace with a functions app',
async () => {
const project = uniq('func');
await runNxCommandAsync(`generate @nxazure/func:init ${project}`);
const buildResult = await runNxCommandAsync(`build ${project}`);

expect(buildResult.stdout).toContain(`Done compiling TypeScript files for project "${project}"`);
},
TEST_TIMEOUT,
);

it(
'should init & build a workspace with a functions app and a function',
async () => {
const project = uniq('func');
const func = 'hello';

await runNxCommandAsync(`generate @nxazure/func:init ${project}`);
await runNxCommandAsync(`generate @nxazure/func:new ${func} --project=${project} --template="HTTP trigger"`);
const buildResult = await runNxCommandAsync(`build ${project}`);

expect(buildResult.stdout).toContain(`Done compiling TypeScript files for project "${project}"`);
},
TEST_TIMEOUT,
);

it(
'should init & build a workspace with a js lib and, a functions app and a function that uses that lib',
async () => {
Expand Down Expand Up @@ -134,34 +109,4 @@ describe('Project initialization and build', () => {
},
TEST_TIMEOUT,
);

it(
'Use strict mode',
async () => {
const project = uniq('func');
await runNxCommandAsync(`generate @nxazure/func:init ${project}`);

const tsConfig = await readJson<{ compilerOptions: CompilerOptions }>(`apps/${project}/tsconfig.json`);
const tsBuildConfig = await readJson<{ compilerOptions: CompilerOptions }>(`apps/${project}/tsconfig.build.json`);

expect(tsConfig.compilerOptions.strict).toBe(true);
expect(tsBuildConfig.compilerOptions.strict).toBe(true);
},
TEST_TIMEOUT,
);

it(
'Use no strict mode',
async () => {
const project = uniq('func');
await runNxCommandAsync(`generate @nxazure/func:init ${project} --no-strict`);

const tsConfig = await readJson<{ compilerOptions: CompilerOptions }>(`apps/${project}/tsconfig.json`);
const tsBuildConfig = await readJson<{ compilerOptions: CompilerOptions }>(`apps/${project}/tsconfig.build.json`);

expect(tsConfig.compilerOptions.strict).toBe(false);
expect(tsBuildConfig.compilerOptions.strict).toBe(false);
},
TEST_TIMEOUT,
);
});

0 comments on commit cc0831f

Please sign in to comment.