Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add E2E test for create-analog with next release of Angular #687

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions apps/create-analog-e2e/tests/create-analog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,61 @@ describe('create-analog e2e', () => {

rmdirSync(tmpDir, { recursive: true });
}, 120000);

it('should create my-app with the next release', async () => {
const project = uniq('tmpanalogapp');
const tmpDir = `${process.cwd()}/${project}`;

await runCommandAsync(
`node ./dist/packages/create-analog/index.js ${project} --template angular-v16 --skipTailwind true`,
{ cwd: process.cwd() }
);

await runCommandAsync(`npm i`, {
cwd: tmpDir,
});

await runCommandAsync(
`ng update @angular/cli @angular/core --next --allow-dirty`,
{
cwd: tmpDir,
}
);

emptyDir(`${tmpDir}/node_modules/@analogjs`);
copyDir(
`${process.cwd()}/node_modules/@analogjs`,
`${tmpDir}/node_modules/@analogjs`
);

let viteConfig = readFileSync(`${tmpDir}/vite.config.ts`, 'utf-8');
viteConfig = viteConfig.replace(
'analog()',
`analog({ vite: { tsconfig: '${tmpDir}/tsconfig.spec.json' } })`
);
viteConfig = viteConfig.replace(
`setupFiles: ['src/test.ts'],`,
`setupFiles: ['${project}/src/test.ts'],`
);
viteConfig = viteConfig.replace(
`include: ['**/*.spec.ts'],`,
`include: ['${project}/**/*.spec.ts'],`
);

writeFileSync(`${tmpDir}/vite.config.ts`, viteConfig);

await runCommandAsync(`ng test`, {
cwd: tmpDir,
});

await runCommandAsync(`ng build`, {
cwd: tmpDir,
});

expect(() =>
checkFilesExist(`${tmpDir}/dist/client/index.html`)
).not.toThrow();

rmdirSync(tmpDir, { recursive: true });
}, 120000);
});
3 changes: 2 additions & 1 deletion packages/create-analog/template-angular-v16/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"options": {
"configFile": "vite.config.ts",
"main": "src/main.ts",
"outputPath": "dist/client"
"outputPath": "dist/client",
"tsConfig": "tsconfig.app.json"
},
"defaultConfiguration": "production",
"configurations": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function addAnalogProjectConfig(
main: `${workspaceAppsDir}${projectName}/src/main.ts`,
configFile: `${workspaceAppsDir}${projectName}/vite.config.ts`,
outputPath: `dist/${workspaceAppsDir}${projectName}/client`,
tsConfig: `${workspaceAppsDir}${projectName}/tsconfig.app.json`,
},
defaultConfiguration: 'production',
configurations: {
Expand Down