Skip to content

Commit

Permalink
Test default template tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoBrusa committed Jan 17, 2023
1 parent c107d96 commit 1984b4f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/releases/4.0.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Some noteworthy breaking changes:
[this blogpost](https://jestjs.io/blog/2022/04/25/jest-28#future) - Any
snapshots tests will have to be updated with the new format, or you can
override the snapshotFormat option to the old defaults.
- As of Jest 28 Jest-Environment-JSDOM is no longer shipped with Jest and needs
- As of Jest 28 jest-environment-jsdom is no longer shipped with Jest and needs
to be installed separately
- Jest now includes full support of package.json exports - some existing imports
might not resolve correctly
Expand Down
67 changes: 67 additions & 0 deletions packages/modular-scripts/src/__tests__/addPackage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
mockInstallTemplate,
runModularForTests,
runModularForTestsAsync,
runModularPipeLogs,
} from '../test/utils';
import type { CoreProperties } from '@schemastore/package';

Expand Down Expand Up @@ -221,3 +222,69 @@ describe('When adding a module from a template with a files filter', () => {
`);
});
});

describe('When creating a new modular project', () => {
beforeAll(() => {
tempModularRepo = createModularTestContext();
});
describe('When adding a new app type workspace from template', () => {
beforeAll(() => {
runModularForTests(tempModularRepo, 'add my-app --template app');
});
it('succesfully runs tests', () => {
const result = runModularPipeLogs(
tempModularRepo,
'test --package my-app',
);
expect(result.exitCode).toBe(0);
});
});
describe('When adding a new package type workspace from template', () => {
beforeAll(() => {
runModularForTests(tempModularRepo, 'add my-package --template package');
});
it('succesfully runs tests', () => {
const result = runModularPipeLogs(
tempModularRepo,
'test --package my-package',
);
expect(result.exitCode).toBe(0);
});
});
});
describe('When adding a new esm-view type workspace from template', () => {
beforeAll(() => {
runModularForTests(tempModularRepo, 'add my-esm-view --template esm-view');
});
it('succesfully runs tests', () => {
const result = runModularPipeLogs(
tempModularRepo,
'test --package my-esm-view',
);
expect(result.exitCode).toBe(0);
});
});
describe('When adding a new view type workspace from template', () => {
beforeAll(() => {
runModularForTests(tempModularRepo, 'add my-view --template view');
});
it('succesfully runs tests', () => {
const result = runModularPipeLogs(
tempModularRepo,
'test --package my-view',
);
expect(result.exitCode).toBe(0);
});
});
describe('When adding a new source type workspace from template', () => {
beforeAll(() => {
runModularForTests(tempModularRepo, 'add my-source --template source');
});
it('succesfully runs tests', () => {
const result = runModularPipeLogs(
tempModularRepo,
'test --package my-source',
);
expect(result.exitCode).toBe(0);
});
});
8 changes: 8 additions & 0 deletions packages/modular-scripts/src/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ export function createModularTestContext(): string {
fs.writeJSONSync(path.join(tempModularRepo, 'package.json'), packageJson, {
spaces: 2,
});
fs.writeJSONSync(path.join(tempModularRepo, 'tsconfig.json'), {
extends: 'modular-scripts/tsconfig.json',
include: ['modular', 'packages/**/src'],
});
fs.copySync(
path.join(modularRoot, 'modular'),
path.join(tempModularRepo, 'modular'),
);
return tempModularRepo;
}

Expand Down

0 comments on commit 1984b4f

Please sign in to comment.