Skip to content

Commit

Permalink
fix(angular): set webpack base so angular assets load (#24106)
Browse files Browse the repository at this point in the history
* fix(angular): set webpack base so angular assets load
  • Loading branch information
jordanpowell88 authored Oct 4, 2022
1 parent d9c5e57 commit c186783
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion npm/webpack-dev-server/src/makeDefaultWebpackConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export function makeDefaultWebpackConfig (
new HtmlWebpackPlugin({
template: indexHtmlFile,
// Angular generates all of it's scripts with <script type="module">. Live-reloading breaks without this option.
...(config.devServerConfig.framework === 'angular' ? { scriptLoading: 'module' } : {}),
// We need to manually set the base here to `/__cypress/src/` so that static assets load with our proxy
...(config.devServerConfig.framework === 'angular' ? { scriptLoading: 'module', base: '/__cypress/src/' } : {}),
}),
],
devtool: 'inline-source-map',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Component } from "@angular/core";

@Component({
selector: 'app-logo',
template: `<img src="assets/cypress-logo-light.png" />`
})
export class LogoComponent {}
6 changes: 6 additions & 0 deletions system-tests/project-fixtures/angular/src/app/mount.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { createOutputSpy } from 'cypress/angular';
import { EventEmitter, Component } from '@angular/core';
import { ProjectionComponent } from "./components/projection.component";
import { LifecycleComponent } from "./components/lifecycle.component";
import { LogoComponent } from "./components/logo.component";

@Component({
template: `<app-projection>Hello World</app-projection>`
Expand Down Expand Up @@ -218,6 +219,11 @@ describe("angular mount", () => {
cy.get('p').should('have.text', 'Hi . ngOnInit fired: true and ngOnChanges fired: false and conditionalName: false')
})

it('can load static assets', () => {
cy.mount(LogoComponent)
cy.get('img').should('be.visible').and('have.prop', 'naturalWidth').should('be.greaterThan', 0)
})


describe("teardown", () => {
beforeEach(() => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

5 comments on commit c186783

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c186783 Oct 4, 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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/linux-x64/develop-c18678381ca3ab35c4ab91fdf98b5c8cf537bd21/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c186783 Oct 4, 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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/linux-arm64/develop-c18678381ca3ab35c4ab91fdf98b5c8cf537bd21/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c186783 Oct 4, 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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/darwin-x64/develop-c18678381ca3ab35c4ab91fdf98b5c8cf537bd21/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c186783 Oct 4, 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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/win32-x64/develop-c18678381ca3ab35c4ab91fdf98b5c8cf537bd21/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on c186783 Oct 4, 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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.10.0/darwin-arm64/develop-c18678381ca3ab35c4ab91fdf98b5c8cf537bd21/cypress.tgz

Please sign in to comment.