Skip to content

Commit

Permalink
fix: use srcRoot for angular build context (#25090)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 authored Dec 16, 2022
1 parent 3617aaf commit 7c36118
Show file tree
Hide file tree
Showing 17 changed files with 5,797 additions and 1 deletion.
2 changes: 1 addition & 1 deletion npm/webpack-dev-server/src/helpers/angularHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function createFakeContext (projectRoot: string, defaultProjectConfig: Cypress.A
getProjectMetadata: () => {
return {
root: defaultProjectConfig.root,
sourceRoot: defaultProjectConfig.root,
sourceRoot: defaultProjectConfig.sourceRoot,
projectType: 'application',
}
},
Expand Down
66 changes: 66 additions & 0 deletions system-tests/projects/angular-custom-root/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular": {
"projectType": "application",
"root": "",
"sourceRoot": "ui",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/angular",
"index": "ui/index.html",
"main": "ui/main.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"ui/favicon.ico"
],
"styles": [
"ui/styles.scss"
]
},
"configurations": {
"production": {
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"browserTarget": "angular:build:production"
},
"development": {
"browserTarget": "angular:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "angular:build"
}
}
}
}
},
"cli": {
"analytics": false
}
}
26 changes: 26 additions & 0 deletions system-tests/projects/angular-custom-root/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { defineConfig } from 'cypress'

export default defineConfig({
component: {
devServer: {
framework: 'angular',
bundler: 'webpack',
webpackConfig: {
resolve: {
alias: {
'@angular/common': require.resolve('@angular/common'),
'@angular/core/testing': require.resolve('@angular/core/testing'),
'@angular/core': require.resolve('@angular/core'),
'@angular/platform-browser/testing': require.resolve('@angular/platform-browser/testing'),
'@angular/platform-browser': require.resolve('@angular/platform-browser'),
'@angular/platform-browser-dynamic/testing': require.resolve('@angular/platform-browser-dynamic/testing'),
'@angular/platform-browser-dynamic': require.resolve('@angular/platform-browser-dynamic'),
'zone.js/testing': require.resolve('zone.js/dist/zone-testing'),
'zone.js': require.resolve('zone.js'),
},
},
},
},
specPattern: '**/*.cy.ts',
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="cypress" />
import { mount } from 'cypress/angular'

declare global {
namespace Cypress {
interface Chainable {
mount: typeof mount
}
}
}

Cypress.Commands.add('mount', mount)

// Example use:
// cy.mount(MyComponent)
27 changes: 27 additions & 0 deletions system-tests/projects/angular-custom-root/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "angular",
"version": "0.0.0",
"private": true,
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development"
},
"dependencies": {
"@angular/common": "^15.0.3",
"@angular/compiler": "^15.0.3",
"@angular/core": "^15.0.3",
"@angular/platform-browser": "^15.0.3",
"@angular/platform-browser-dynamic": "^15.0.3",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.0.3",
"@angular/cli": "~15.0.3",
"@angular/compiler-cli": "^15.0.3",
"typescript": "~4.8.4"
}
}
13 changes: 13 additions & 0 deletions system-tests/projects/angular-custom-root/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"ui/main.ts"
],
"include": [
"ui/**/*.d.ts"
]
}
33 changes: 33 additions & 0 deletions system-tests/projects/angular-custom-root/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"moduleResolution": "node",
"importHelpers": true,
"target": "ES2022",
"module": "es2020",
"lib": [
"es2020",
"dom"
],
"useDefineForClassFields": false
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { AppComponent } from './app.component'

describe('AppComponent', () => {
it('should mount', () => {
cy.mount(AppComponent)
cy.contains('h1', 'Hello World!')
})
})
14 changes: 14 additions & 0 deletions system-tests/projects/angular-custom-root/ui/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Component } from '@angular/core'

@Component({
selector: 'app-root',
template: '<h1>{{message}}</h1>',
styles: [`
h1 {
background-color: blue;
color: white
}`],
})
export class AppComponent {
message = 'Hello World!'
}
11 changes: 11 additions & 0 deletions system-tests/projects/angular-custom-root/ui/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'

import { AppComponent } from './app.component'

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule],
bootstrap: [AppComponent],
})
export class AppModule {}
Binary file not shown.
13 changes: 13 additions & 0 deletions system-tests/projects/angular-custom-root/ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Angular</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
</body>
</html>
8 changes: 8 additions & 0 deletions system-tests/projects/angular-custom-root/ui/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'

import { AppModule } from './app/app.module'

import 'zone.js' // Included with Angular CLI.

platformBrowserDynamic().bootstrapModule(AppModule)
.catch((err) => console.error(err))
3 changes: 3 additions & 0 deletions system-tests/projects/angular-custom-root/ui/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* {
box-sizing: border-box;
}
Loading

5 comments on commit 7c36118

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c36118 Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/linux-x64/develop-7c361187e31c3681f415da8a9073221d807987f6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c36118 Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/darwin-arm64/develop-7c361187e31c3681f415da8a9073221d807987f6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c36118 Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/linux-arm64/develop-7c361187e31c3681f415da8a9073221d807987f6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c36118 Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/darwin-x64/develop-7c361187e31c3681f415da8a9073221d807987f6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 7c36118 Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/12.2.0/win32-x64/develop-7c361187e31c3681f415da8a9073221d807987f6/cypress.tgz

Please sign in to comment.