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

chore(npm/angular): migrate angular adapter to monorepo #16434

Merged
merged 17 commits into from
May 19, 2021

Conversation

lmiller1990
Copy link
Contributor

@lmiller1990 lmiller1990 commented May 11, 2021

  • Closes N/A

User facing changelog

Migrate Angular adapter into monorepo from https://www.npmjs.com/package/cypress-angular-unit-test.

Still WIP. It's marked private: true so it won't go to npm yet.

Additional details

Consolidate all major adapters (Vue, React, Angular) in a single place This supports better code sharing, and the ability to run their test suite against the latest Cypress commits.

How has the user experience changed?

PR Tasks

  • Have tests been added/updated?
  • Has the original issue or this PR been tagged with a release in ZenHub?
  • Has a PR for user-facing changes been opened in cypress-documentation?
  • Have API changes been updated in the type definitions?
  • Have new configuration options been added to the cypress.schema.json?

@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 11, 2021

Thanks for taking the time to open a PR!

@lmiller1990 lmiller1990 changed the title chore:(npm/angular) migrate angular adapter to monorepo chore(npm/angular) migrate angular adapter to monorepo May 11, 2021
@cypress
Copy link

cypress bot commented May 11, 2021



Test summary

4074 0 50 2Flakiness 0


Run details

Project cypress
Status Passed
Commit 121f8ed
Started May 19, 2021 1:19 AM
Ended May 19, 2021 1:29 AM
Duration 10:02 💡
OS Linux Debian - 10.8
Browser Chrome beta 91

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@JessicaSachs
Copy link
Contributor

Nice. Ideally we split up incremental changes such as added tests and code changes into PRs into this branch.

The acceptance criteria for this PR is that:

  • @cypress/angular can be cloned and locally linked to a new, scaffolded angular project.
  • A test harness exists within @cypress/angular to launch CT

@lmiller1990 lmiller1990 changed the title chore(npm/angular) migrate angular adapter to monorepo chore(npm/angular): migrate angular adapter to monorepo May 12, 2021
@lmiller1990
Copy link
Contributor Author

lmiller1990 commented May 13, 2021

Trying to test but cannot create a new angular app using the angular-cli. Weird.

Edit: freak accident, I already had a Vue app called my-awesome-app, and I tried making an angular app w/ the same name... 🤦

@lmiller1990 lmiller1990 marked this pull request as ready for review May 13, 2021 15:07
agg23
agg23 previously approved these changes May 13, 2021
"angular2-template-loader": "0.6.2",
"codelyzer": "6.0.2",
"core-js": "3.12.1",
"cypress": "7.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be local Cypress?

Copy link
Contributor Author

@lmiller1990 lmiller1990 May 13, 2021

Choose a reason for hiding this comment

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

Yes. Well spotted.
The test script uses local, but I will remove this unused and useless dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@lmiller1990 lmiller1990 requested a review from agg23 May 14, 2021 04:10
agg23
agg23 previously approved these changes May 14, 2021
Copy link
Contributor

@elevatebart elevatebart left a comment

Choose a reason for hiding this comment

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

Great PR! I still have a couple of comments.

  • I believe the snapshot images taken by cypress should not be version controlled.
  • npm/angular/src/assets/.gitkeep is unnecessary since we have a logo for cypress besides it

npm/angular/.github/workflows/ci.yml Outdated Show resolved Hide resolved
npm/angular/.github/ISSUE_TEMPLATE/bug_report.md Outdated Show resolved Hide resolved
npm/angular/.prettierrc.json Outdated Show resolved Hide resolved
npm/angular/renovate.json Outdated Show resolved Hide resolved
@lmiller1990
Copy link
Contributor Author

@elevatebart fixed most of those things. Why don't we add snapshots? I think we need them, so we can diff the new ones with the old ones. This repo uses 'cypress-image-snapshot`, which does the diff between existing ones and new ones - like visual regression.

@elevatebart
Copy link
Contributor

The design-system test are failing because of a classic cypress flake (the element is detached from the DOM)

The tests are fixed in this PR that still needs to be approved/merged.

I believe you will have to do so before this one can pass.

import { NetworkService } from '../network.service'
import { NetworkComponent } from './network.component'

describe('Network', () => {

Choose a reason for hiding this comment

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

I just added an example with cy.intercept :

import { HttpClientModule } from '@angular/common/http';
import { initEnv, mount } from 'cypress-angular-unit-test';
import { NetworkService } from '../network.service';
import { NetworkComponent } from './network.component';

describe('Network', () => {
  describe('No mock', () => {
    beforeEach(() => {
      initEnv(NetworkComponent, {
        providers: [NetworkService],
        imports: [HttpClientModule],
      });
    });

    it('fetches 3 users from remote API', () => {
      mount(NetworkComponent);
      cy.get('li').should('have.length', 3);
    });
  });
  describe('With mock', () => {
    beforeEach(() => {
      cy.intercept('/users?_limit=3', { body: [{ id: 1, name: 'foo' }] });
      initEnv(NetworkComponent, {
        providers: [NetworkService],
        imports: [HttpClientModule],
      });
    });
    it('fetch 1 user stubed', () => {
      mount(NetworkComponent);
      cy.get('li').should('have.length', 1).first().contains('foo');
    });
  });
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add this, thanks.

Feel free to make PRs against this repo if you like 👍 or just ping me and I can make changes (still learning Angular...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@elevatebart elevatebart left a comment

Choose a reason for hiding this comment

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

GOood stuff

@lmiller1990 lmiller1990 merged commit a277e98 into develop May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants