Skip to content

Commit

Permalink
fix(nx-serverless): update e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
NarongOk committed Oct 12, 2024
1 parent 6fb44b6 commit 43c4462
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
11 changes: 8 additions & 3 deletions apps/nx-serverless-e2e/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module.exports = {
name: 'nx-serverless-e2e',
preset: '../../jest.config.js',
coverageDirectory: '../../coverage/apps\nx-serverless-e2e'
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
coverageDirectory: '../../coverage/apps\nx-serverless-e2e',
displayName: 'nx-serverless-e2e',
testEnvironment: 'node',
};
23 changes: 9 additions & 14 deletions apps/nx-serverless-e2e/tests/nx-serverless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,23 @@ import {
runNxCommandAsync,
uniq,
} from '@nx/plugin/testing';

describe('nx-serverless e2e', () => {
beforeAll(() => {
ensureNxProject('@flowaccount/nx-serverless', 'dist/libs/nx-serverless');
});
describe('nx-serverless:api-serverless e2e', () => {
it('should create nx-serverless:api-serverless', async (done) => {
it('should create nx-serverless:api-serverless', async () => {
const plugin = uniq('nx-serverless');
await runNxCommandAsync(
`generate @flowaccount/nx-serverless:api-serverless ${plugin}`
);
const result = await runNxCommandAsync(`build ${plugin}`);
expect(result.stdout).toContain(`[./apps/${plugin}/src/handler.ts]`);
done();
}, 90000);

describe('--directory', () => {
it('should create src in the specified directory', async (done) => {
it('should create src in the specified directory', async () => {
const plugin = uniq('nx-serverless');
await runNxCommandAsync(
`generate @flowaccount/nx-serverless:api-serverless ${plugin} --directory subdir`
Expand All @@ -39,43 +40,39 @@ describe('nx-serverless e2e', () => {
`apps/subdir/${plugin}/tslint.json`
)
).not.toThrow();
done();
}, 10000);
});

describe('--tags', () => {
it('should add tags to nx.json', async (done) => {
it('should add tags to nx.json', async () => {
const plugin = uniq('nx-serverless');
await runNxCommandAsync(
`generate @flowaccount/nx-serverless:api-serverless ${plugin} --tags e2etag,e2ePackage`
);
const nxJson = readJson('nx.json');
expect(nxJson.projects[plugin].tags).toEqual(['e2etag', 'e2ePackage']);
done();
}, 10000);
});
}),
describe('nx-serverless:express e2e test', () => {
it('should create nx-serverless:express', async (done) => {
it('should create nx-serverless:express', async () => {
const plugin = uniq('nx-serverless-express');
await runNxCommandAsync(
`generate @flowaccount/nx-serverless:express ${plugin} --initExpress true`
);
const result = await runNxCommandAsync(`build ${plugin}`);
expect(result.stdout).toContain('Built at:');
done();
}, 90000);
it('should compile nx-serverless:express', async (done) => {
it('should compile nx-serverless:express', async () => {
const plugin = uniq('nx-serverless-express');
await runNxCommandAsync(
`generate @flowaccount/nx-serverless:express ${plugin} --initExpress true`
);
const result = await runNxCommandAsync(`run ${plugin}:compile`);
expect(result.stdout).toContain(`Done compiling TypeScript files`);
done();
}, 90000);
describe('--directory', () => {
it('should create src in the specified directory', async (done) => {
it('should create src in the specified directory', async () => {
const plugin = uniq('nx-serverless-express');
await runNxCommandAsync(
`generate @flowaccount/nx-serverless:express ${plugin} --directory subdir --initExpress true`
Expand All @@ -96,12 +93,11 @@ describe('nx-serverless e2e', () => {
`apps/subdir/${plugin}/tslint.json`
)
).not.toThrow();
done();
}, 10000);
});

describe('--tags', () => {
it('should add tags to nx.json', async (done) => {
it('should add tags to nx.json', async () => {
const plugin = uniq('nx-serverless-express');
await runNxCommandAsync(
`generate @flowaccount/nx-serverless:express ${plugin} --tags e2etag,e2ePackage --initExpress=true`
Expand All @@ -111,7 +107,6 @@ describe('nx-serverless e2e', () => {
'e2etag',
'e2ePackage',
]);
done();
}, 10000);
});
});
Expand Down
3 changes: 2 additions & 1 deletion apps/nx-serverless-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"types": ["node", "jest"]
"types": ["node", "jest"],
"esModuleInterop": true
},
"include": [],
"files": [],
Expand Down

0 comments on commit 43c4462

Please sign in to comment.