├── .circleci └── config.yml ├── .codeclimate.yml ├── .commitlintrc.yml ├── .dockerignore ├── .editorconfig ├── .eslintignore ├── .eslintrc.yml ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ └── feature_request.md ├── dependabot.yml └── workflows │ └── codeql.yml ├── .gitignore ├── .husky ├── .gitignore ├── commit-msg ├── post-commit ├── pre-commit └── pre-push ├── .lintstagedrc.js ├── .nvmrc ├── .prettierignore ├── .prettierrc.yml ├── .releaserc.yml ├── CHANGELOG.md ├── CODEOWNERS ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── compose.sh ├── compose.yml ├── docs ├── .gitignore ├── .nvmrc ├── articles │ ├── api │ │ ├── MockBuilder.md │ │ ├── MockComponent.md │ │ ├── MockDirective.md │ │ ├── MockInstance.md │ │ ├── MockModule.md │ │ ├── MockPipe.md │ │ ├── MockProvider.md │ │ ├── MockRender.md │ │ ├── MockService.md │ │ ├── helpers │ │ │ ├── getMockedNgDefOf.md │ │ │ ├── getSourceOfMock.md │ │ │ ├── isMockControlValueAccessor.md │ │ │ ├── isMockOf.md │ │ │ ├── isMockValidator.md │ │ │ ├── isMockedNgDefOf.md │ │ │ ├── isNgDef.md │ │ │ └── isNgInjectionToken.md │ │ ├── ngMocks.md │ │ └── ngMocks │ │ │ ├── change.md │ │ │ ├── click.md │ │ │ ├── crawl.md │ │ │ ├── defaultConfig.md │ │ │ ├── defaultMock.md │ │ │ ├── event.md │ │ │ ├── faster.md │ │ │ ├── find.md │ │ │ ├── findAll.md │ │ │ ├── findInstance.md │ │ │ ├── findInstances.md │ │ │ ├── findTemplateRef.md │ │ │ ├── findTemplateRefs.md │ │ │ ├── flushTestBed.md │ │ │ ├── formatHtml.md │ │ │ ├── formatText.md │ │ │ ├── get.md │ │ │ ├── globalExclude.md │ │ │ ├── globalKeep.md │ │ │ ├── globalMock.md │ │ │ ├── globalReplace.md │ │ │ ├── globalWipe.md │ │ │ ├── guts.md │ │ │ ├── hide.md │ │ │ ├── ignoreOnConsole.md │ │ │ ├── input.md │ │ │ ├── output.md │ │ │ ├── render.md │ │ │ ├── reset.md │ │ │ ├── reveal.md │ │ │ ├── revealAll.md │ │ │ ├── stub.md │ │ │ ├── stubMember.md │ │ │ ├── throwOnConsole.md │ │ │ ├── touch.md │ │ │ └── trigger.md │ ├── credits.md │ ├── extra │ │ ├── auto-spy.md │ │ ├── customize-mocks.md │ │ ├── extensive-example.md │ │ ├── how-to-write-tests.md │ │ ├── install.md │ │ ├── mock-form-controls.md │ │ ├── mock-observables.md │ │ ├── quick-start.md │ │ ├── sanitizer.md │ │ ├── templateref.md │ │ └── with-3rd-party.md │ ├── guides.md │ ├── guides │ │ ├── component-provider.md │ │ ├── component-standalone.md │ │ ├── component.md │ │ ├── directive-attribute.md │ │ ├── directive-provider.md │ │ ├── directive-standalone.md │ │ ├── directive-structural-context.md │ │ ├── directive-structural.md │ │ ├── host-directive.md │ │ ├── http-interceptor.md │ │ ├── http-request.md │ │ ├── lazy-loaded-module.md │ │ ├── libraries │ │ │ ├── angular-material.md │ │ │ ├── ng-select.md │ │ │ ├── ngrx.md │ │ │ ├── ngxs.md │ │ │ └── primeng.md │ │ ├── mock │ │ │ ├── activated-route.md │ │ │ ├── directive-structural-let-of.md │ │ │ ├── dynamic-components.md │ │ │ ├── host-directive.md │ │ │ └── initialization-logic.md │ │ ├── ngonchanges.md │ │ ├── pipe-standalone.md │ │ ├── pipe.md │ │ ├── provider.md │ │ ├── route.md │ │ ├── routing-guard.md │ │ ├── routing-resolver.md │ │ ├── token-multi.md │ │ ├── token.md │ │ └── view-child.md │ ├── index.md │ ├── migrations.md │ ├── need-help.md │ ├── tl-dr.md │ └── troubleshooting │ │ ├── browser-animations-module.md │ │ ├── component-id-generation-collision-detected.md │ │ ├── declarations-of-2-modules.md │ │ ├── faq.md │ │ ├── internals-vs-externals.md │ │ ├── multiple-components-match-node-with-tagname.md │ │ ├── no-selector.md │ │ ├── not-a-known-element.md │ │ └── read-property-of-undefined.md ├── babel.config.js ├── docusaurus.config.js ├── package-lock.json ├── package.json ├── sidebars.js ├── src │ └── css │ │ └── custom.css ├── static │ ├── .htaccess │ ├── .nojekyll │ ├── img │ │ └── favicon.ico │ └── robots.txt └── style-guide.md ├── e2e ├── a10 │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.es2015ivy.js │ ├── jest.es2015noivy.js │ ├── jest.es5ivy.js │ ├── jest.es5noivy.js │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ ├── tsconfig.es2015ivy.spec.json │ ├── tsconfig.es2015noivy.spec.json │ ├── tsconfig.es5ivy.spec.json │ ├── tsconfig.es5noivy.spec.json │ └── tsconfig.json ├── a11 │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.es2015ivy.js │ ├── jest.es2015noivy.js │ ├── jest.es5ivy.js │ ├── jest.es5noivy.js │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ ├── tsconfig.es2015ivy.spec.json │ ├── tsconfig.es2015noivy.spec.json │ ├── tsconfig.es5ivy.spec.json │ ├── tsconfig.es5noivy.spec.json │ └── tsconfig.json ├── a12 │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.es2015ivy.js │ ├── jest.es5ivy.js │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ ├── tsconfig.es2015ivy.spec.json │ ├── tsconfig.es5ivy.spec.json │ └── tsconfig.json ├── a13 │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.es2015ivy.js │ ├── jest.es5ivy.js │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ ├── tsconfig.es2015ivy.spec.json │ ├── tsconfig.es5ivy.spec.json │ └── tsconfig.json ├── a14 │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.es2015ivy.js │ ├── jest.es5ivy.js │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.es2015ivy.spec.json │ ├── tsconfig.es5ivy.spec.json │ └── tsconfig.json ├── a15 │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ └── tsconfig.json ├── a16 │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ └── tsconfig.json ├── a17 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ └── tsconfig.json ├── a18 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ └── tsconfig.json ├── a19 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ └── tsconfig.json ├── a20 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ └── tsconfig.json ├── a5es2015 │ ├── .angular-cli.json │ ├── .gitignore │ ├── .nvmrc │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ ├── test.ts │ │ ├── tsconfig.app.json │ │ ├── tsconfig.spec.json │ │ └── typings.d.ts │ └── tsconfig.json ├── a5es5 │ ├── .angular-cli.json │ ├── .gitignore │ ├── .nvmrc │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ ├── test.ts │ │ ├── tsconfig.app.json │ │ ├── tsconfig.spec.json │ │ └── typings.d.ts │ └── tsconfig.json ├── a6 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.es2015.js │ ├── jest.es5.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── browserslist │ │ ├── index.html │ │ ├── karma.conf.js │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ ├── test.ts │ │ └── tslint.json │ ├── tsconfig.es2015.spec.json │ ├── tsconfig.es5.spec.json │ └── tsconfig.json ├── a7 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.es2015.js │ ├── jest.es5.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── browserslist │ │ ├── index.html │ │ ├── karma.conf.js │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ ├── test.ts │ │ └── tslint.json │ ├── tsconfig.es2015.spec.json │ ├── tsconfig.es5.spec.json │ └── tsconfig.json ├── a8 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── browserslist │ ├── jest.es2015.js │ ├── jest.es5.js │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ ├── tsconfig.es2015.spec.json │ ├── tsconfig.es5.spec.json │ └── tsconfig.json ├── a9 │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── browserslist │ ├── jest.es2015ivy.js │ ├── jest.es2015noivy.js │ ├── jest.es5ivy.js │ ├── jest.es5noivy.js │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── setup-jest.ts │ │ └── test.ts │ ├── tsconfig.es2015ivy.spec.json │ ├── tsconfig.es2015noivy.spec.json │ ├── tsconfig.es5ivy.spec.json │ ├── tsconfig.es5noivy.spec.json │ └── tsconfig.json ├── jasmine │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── test.ts │ │ └── tests │ │ │ └── issue-000 │ │ │ ├── app.component.ts │ │ │ ├── app.module.ts │ │ │ ├── app.service.ts │ │ │ └── issue-000.spec.ts │ └── tsconfig.json ├── jest │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── setup-jest.ts │ │ └── tests │ │ │ ├── issue-000 │ │ │ ├── app.component.ts │ │ │ ├── app.module.ts │ │ │ ├── app.service.ts │ │ │ └── issue-000.spec.ts │ │ │ ├── issue-3811 │ │ │ ├── __snapshots__ │ │ │ │ └── test.spec.ts.snap │ │ │ └── test.spec.ts │ │ │ └── issue-760 │ │ │ ├── 1.fixtures.ts │ │ │ ├── 2.fixtures.ts │ │ │ └── test.spec.ts │ └── tsconfig.json ├── min │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── angular.json │ ├── jest.config.ts │ ├── karma.conf.js │ ├── ng-package.json │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── index.html │ │ ├── main.ts │ │ ├── setup-jest.ts │ │ ├── test.ts │ │ └── tests │ │ │ ├── issue-000 │ │ │ ├── app.component.html │ │ │ ├── app.component.ts │ │ │ ├── app.module.ts │ │ │ └── issue-000.spec.ts │ │ │ └── issue-857 │ │ │ └── test.spec.ts │ └── tsconfig.json └── nx │ ├── .browserslistrc │ ├── .gitignore │ ├── .nvmrc │ ├── jest.config.ts │ ├── jest.preset.js │ ├── nx.json │ ├── package-lock.json │ ├── package.json │ ├── project.json │ ├── src │ ├── index.html │ ├── main.ts │ └── test-setup.ts │ ├── tsconfig.json │ └── tsconfig.spec.json ├── empty.ts ├── examples ├── MockActivatedRoute │ └── test.spec.ts ├── MockBuilder │ ├── spec.components.fixtures.ts │ ├── spec.directives.fixtures.ts │ ├── spec.modules.fixtures.ts │ ├── spec.pipes.fixtures.ts │ ├── spec.services.fixtures.ts │ ├── spec.tokens.fixtures.ts │ ├── test.deep.spec.ts │ ├── test.ng-mocks.spec.ts │ ├── test.promise.spec.ts │ └── test.simple.spec.ts ├── MockComponent │ └── test.spec.ts ├── MockDirective-Attribute │ └── test.spec.ts ├── MockDirective-Structural │ └── test.spec.ts ├── MockForms │ └── test.spec.ts ├── MockHostDirective │ └── test.spec.ts ├── MockInitializationLogic │ └── test.spec.ts ├── MockInstance │ ├── component.spec.ts │ └── test.spec.ts ├── MockModule │ └── test.spec.ts ├── MockObservable │ └── test.spec.ts ├── MockPipe │ └── test.spec.ts ├── MockProvider │ └── test.spec.ts ├── MockReactiveForms │ └── test.spec.ts ├── MockRender │ └── test.spec.ts ├── MockSanitizer │ └── test.spec.ts ├── MockViewChild │ └── test.spec.ts ├── TestAttributeDirective │ └── test.spec.ts ├── TestDirectiveLetOf │ ├── dynamic.spec.ts │ └── static.spec.ts ├── TestHostDirective │ └── test.spec.ts ├── TestHttpInterceptor │ └── test.spec.ts ├── TestHttpRequest │ └── test.spec.ts ├── TestLazyModule │ ├── lazy-module.ts │ └── test.spec.ts ├── TestLifecycleHooks │ ├── fixtures.ts │ ├── test.spec.ts │ ├── test.string.spec.ts │ └── test.type-without-params.spec.ts ├── TestMultiToken │ └── test.spec.ts ├── TestPipe │ └── test.spec.ts ├── TestProvider │ └── test.spec.ts ├── TestProviderInComponent │ └── test.spec.ts ├── TestProviderInDirective │ └── test.spec.ts ├── TestProviderWithDependencies │ └── test.spec.ts ├── TestProviderWithUseClass │ └── test.spec.ts ├── TestProviderWithUseExisting │ └── test.spec.ts ├── TestProviderWithUseFactory │ └── test.spec.ts ├── TestProviderWithUseValue │ └── test.spec.ts ├── TestRoute │ └── test.spec.ts ├── TestRoutingGuard │ ├── can-activate-child.spec.ts │ ├── can-activate.spec.ts │ ├── can-deactivate.spec.ts │ ├── can-load.spec.ts │ ├── can-match.spec.ts │ └── test.spec.ts ├── TestRoutingResolver │ ├── fn.spec.ts │ └── test.spec.ts ├── TestStandaloneComponent │ └── test.spec.ts ├── TestStandaloneDirective │ └── test.spec.ts ├── TestStandalonePipe │ └── test.spec.ts ├── TestStructuralDirective │ └── test.spec.ts ├── TestStructuralDirectiveWithContext │ └── test.spec.ts ├── TestTemplateRefByDirective │ └── test.spec.ts ├── TestTemplateRefById │ └── test.spec.ts ├── TestTemplateRefByRender │ └── test.spec.ts ├── TestToken │ └── test.spec.ts ├── TestViewChild │ └── test.spec.ts ├── main │ └── test.spec.ts ├── ngMocksFaster │ └── test.spec.ts ├── ngMocksGuts │ └── test.spec.ts └── readme │ ├── builder.spec.ts │ └── classic.spec.ts ├── karma.conf.ts ├── karma.ie.sh ├── libs └── ng-mocks │ ├── migrations.json │ ├── package.json │ ├── src │ ├── index.ts │ └── lib │ │ ├── common │ │ ├── core.config.ts │ │ ├── core.def-stack.spec.ts │ │ ├── core.def-stack.ts │ │ ├── core.define-property.ts │ │ ├── core.form.ts │ │ ├── core.helpers.spec.ts │ │ ├── core.helpers.ts │ │ ├── core.injector.ts │ │ ├── core.reflect.body-catch.ts │ │ ├── core.reflect.directive-resolve.ts │ │ ├── core.reflect.meta.ts │ │ ├── core.reflect.module-resolve.ts │ │ ├── core.reflect.parameters-resolve.ts │ │ ├── core.reflect.pipe-resolve.ts │ │ ├── core.reflect.provided-in.spec.ts │ │ ├── core.reflect.provided-in.ts │ │ ├── core.tokens.ts │ │ ├── core.types.ts │ │ ├── decorate.inputs.ts │ │ ├── decorate.mock.ts │ │ ├── decorate.outputs.ts │ │ ├── decorate.queries.ts │ │ ├── error.empty-def.spec.ts │ │ ├── error.empty-def.ts │ │ ├── error.jest-mock.ts │ │ ├── error.missing-decorators.ts │ │ ├── func.directive-io-build.ts │ │ ├── func.directive-io-parse.ts │ │ ├── func.extract-deps.ts │ │ ├── func.extract-forward-ref.ts │ │ ├── func.get-global.ts │ │ ├── func.get-mocked-ng-def-of.ts │ │ ├── func.get-name.spec.ts │ │ ├── func.get-name.ts │ │ ├── func.get-ng-type.ts │ │ ├── func.get-source-of-mock.ts │ │ ├── func.get-type.ts │ │ ├── func.import-exists.ts │ │ ├── func.is-jest-mock.spec.ts │ │ ├── func.is-jest-mock.ts │ │ ├── func.is-mock-control-value-accessor.spec.ts │ │ ├── func.is-mock-control-value-accessor.ts │ │ ├── func.is-mock-ng-def.ts │ │ ├── func.is-mock-of.ts │ │ ├── func.is-mock-validator.spec.ts │ │ ├── func.is-mock-validator.ts │ │ ├── func.is-mock.ts │ │ ├── func.is-mocked-ng-def-of.ts │ │ ├── func.is-ng-def.ts │ │ ├── func.is-ng-injection-token.ts │ │ ├── func.is-ng-module-def-with-providers.ts │ │ ├── func.is-ng-type.ts │ │ ├── func.is-standalone.ts │ │ ├── func.iterate-declaration.ts │ │ ├── mock-control-value-accessor-proxy.ts │ │ ├── mock-control-value-accessor.ts │ │ ├── mock.spec.ts │ │ ├── mock.ts │ │ ├── ng-mocks-global-overrides.ts │ │ ├── ng-mocks-stack.ts │ │ └── ng-mocks-universe.ts │ │ ├── mock-builder │ │ ├── func.extract-tokens.ts │ │ ├── mock-builder-stash.ts │ │ ├── mock-builder.performance.spec.ts │ │ ├── mock-builder.performance.ts │ │ ├── mock-builder.promise.spec.ts │ │ ├── mock-builder.promise.ts │ │ ├── mock-builder.ts │ │ ├── performance │ │ │ ├── are-equal-config-params.ts │ │ │ ├── are-equal-maps.ts │ │ │ ├── are-equal-providers.ts │ │ │ ├── are-equal-sets.ts │ │ │ ├── equal-render-configs.ts │ │ │ ├── equal-render-defs.ts │ │ │ ├── equal-variables.ts │ │ │ ├── get-empty-config.ts │ │ │ └── required-metadata.ts │ │ ├── promise │ │ │ ├── add-def-to-root-provider-parameters.ts │ │ │ ├── add-requested-providers.ts │ │ │ ├── apply-platform-modules.ts │ │ │ ├── check-root-provider-dependency.ts │ │ │ ├── create-ng-mocks-overrides-token.ts │ │ │ ├── create-ng-mocks-token.ts │ │ │ ├── create-ng-mocks-touches-token.ts │ │ │ ├── extract-dep.ts │ │ │ ├── get-override-def.ts │ │ │ ├── get-root-provider-parameters.ts │ │ │ ├── get-root-providers-data.ts │ │ │ ├── handle-entry-components.ts │ │ │ ├── handle-provided-in-dependency.ts │ │ │ ├── handle-root-providers.ts │ │ │ ├── init-exclude-def.ts │ │ │ ├── init-keep-def.ts │ │ │ ├── init-mock-declarations.ts │ │ │ ├── init-module.ts │ │ │ ├── init-modules.ts │ │ │ ├── init-ng-modules.ts │ │ │ ├── init-replace-def.ts │ │ │ ├── init-universe.ts │ │ │ ├── parse-mock-arguments.ts │ │ │ ├── parse-provider.ts │ │ │ ├── skip-dep.ts │ │ │ ├── skip-override.ts │ │ │ ├── skip-root-provider-dependency.ts │ │ │ ├── try-mock-declaration.ts │ │ │ ├── try-mock-provider.ts │ │ │ └── types.ts │ │ └── types.ts │ │ ├── mock-component │ │ ├── mock-component.spec.child-component.fixtures.ts │ │ ├── mock-component.spec.custom-form-control.component.fixtures.ts │ │ ├── mock-component.spec.empty-component.component.fixtures.ts │ │ ├── mock-component.spec.getter-setter.component.fixtures.ts │ │ ├── mock-component.spec.simple-component.component.fixtures.ts │ │ ├── mock-component.spec.template-outlet.component.fixtures.ts │ │ ├── mock-component.spec.ts │ │ ├── mock-component.ts │ │ ├── render │ │ │ ├── generate-template.ts │ │ │ └── get-key.ts │ │ └── types.ts │ │ ├── mock-declaration │ │ ├── mock-declaration.spec.ts │ │ └── mock-declaration.ts │ │ ├── mock-directive │ │ ├── mock-directive.spec.ts │ │ ├── mock-directive.ts │ │ └── types.ts │ │ ├── mock-helper │ │ ├── crawl │ │ │ ├── crawl-by-attribute-value.spec.ts │ │ │ ├── crawl-by-attribute-value.ts │ │ │ ├── crawl-by-attribute.ts │ │ │ ├── crawl-by-declaration.ts │ │ │ ├── crawl-by-id.ts │ │ │ ├── crawl-by-tag-name.ts │ │ │ ├── detect-attribute-in-selectors.ts │ │ │ ├── detect-crawler.ts │ │ │ ├── detect-selectors-from-node.spec.ts │ │ │ ├── detect-selectors-from-node.ts │ │ │ ├── detect-tag-name-in-selectors.ts │ │ │ ├── detect-text-node.ts │ │ │ ├── el-def-compare.ts │ │ │ ├── el-def-get-node.ts │ │ │ ├── el-def-get-parent.ts │ │ │ ├── func.get-public-provider-keys.ts │ │ │ ├── func.is-valid-reveal-selector.ts │ │ │ ├── func.parse-inputs-and-requires-attributes.spec.ts │ │ │ ├── func.parse-inputs-and-requires-attributes.ts │ │ │ ├── mock-helper.crawl.ts │ │ │ ├── mock-helper.reveal-all.ts │ │ │ ├── mock-helper.reveal.ts │ │ │ ├── nested-check-children.ts │ │ │ ├── nested-check-parent.ts │ │ │ ├── nested-check.spec.ts │ │ │ └── nested-check.ts │ │ ├── cva │ │ │ ├── func.get-vca.ts │ │ │ ├── mock-helper.change.ts │ │ │ └── mock-helper.touch.ts │ │ ├── events │ │ │ ├── mock-helper.click.ts │ │ │ ├── mock-helper.event.ts │ │ │ └── mock-helper.trigger.ts │ │ ├── find-instance │ │ │ ├── func.is-valid-find-instance-selector.ts │ │ │ ├── mock-helper.find-instance.ts │ │ │ └── mock-helper.find-instances.ts │ │ ├── find │ │ │ ├── func.parse-find-args.ts │ │ │ ├── func.parse-find-term.ts │ │ │ ├── mock-helper.find-all.ts │ │ │ └── mock-helper.find.ts │ │ ├── format │ │ │ ├── format-handler.ts │ │ │ ├── handle-array.ts │ │ │ ├── handle-text.ts │ │ │ ├── is-debug-node.ts │ │ │ ├── is-fixture.ts │ │ │ ├── is-html-element.ts │ │ │ ├── is-text.ts │ │ │ ├── mock-helper.format-html.ts │ │ │ ├── mock-helper.format-text.ts │ │ │ └── types.ts │ │ ├── func.get-from-node-element.ts │ │ ├── func.get-from-node-injector.ts │ │ ├── func.get-from-node-ivy.spec.ts │ │ ├── func.get-from-node-ivy.ts │ │ ├── func.get-from-node-scan.ts │ │ ├── func.get-from-node-standard.spec.ts │ │ ├── func.get-from-node-standard.ts │ │ ├── func.get-from-node.ts │ │ ├── func.get-last-fixture.ts │ │ ├── func.global-prepare.ts │ │ ├── func.parse-find-args-name.ts │ │ ├── func.parse-find-args.ts │ │ ├── func.parse-provider-tokens-directives.ts │ │ ├── mock-helper.attributes.ts │ │ ├── mock-helper.auto-spy.ts │ │ ├── mock-helper.console-ignore.ts │ │ ├── mock-helper.console-throw.ts │ │ ├── mock-helper.console.ts │ │ ├── mock-helper.default-config.ts │ │ ├── mock-helper.default-mock.ts │ │ ├── mock-helper.faster-install.ts │ │ ├── mock-helper.faster.ts │ │ ├── mock-helper.flush-test-bed.ts │ │ ├── mock-helper.get.ts │ │ ├── mock-helper.global-exclude.spec.ts │ │ ├── mock-helper.global-exclude.ts │ │ ├── mock-helper.global-keep.spec.ts │ │ ├── mock-helper.global-keep.ts │ │ ├── mock-helper.global-mock.spec.ts │ │ ├── mock-helper.global-mock.ts │ │ ├── mock-helper.global-replace.spec.ts │ │ ├── mock-helper.global-replace.ts │ │ ├── mock-helper.global-wipe.spec.ts │ │ ├── mock-helper.global-wipe.ts │ │ ├── mock-helper.guts.spec.ts │ │ ├── mock-helper.guts.ts │ │ ├── mock-helper.input.ts │ │ ├── mock-helper.object.ts │ │ ├── mock-helper.output.ts │ │ ├── mock-helper.reset.ts │ │ ├── mock-helper.spec.ts │ │ ├── mock-helper.stub-member.ts │ │ ├── mock-helper.stub.ts │ │ ├── mock-helper.ts │ │ ├── render │ │ │ ├── func.find-deep.ts │ │ │ ├── func.parse-template.ts │ │ │ ├── mock-helper.hide.ts │ │ │ └── mock-helper.render.ts │ │ └── template-ref │ │ │ ├── detect-crawler.ts │ │ │ ├── detect-template-ref.ts │ │ │ ├── func.is-valid-template-ref-selector.ts │ │ │ ├── mock-helper.find-template-ref.ts │ │ │ └── mock-helper.find-template-refs.ts │ │ ├── mock-instance │ │ ├── mock-instance-apply.ts │ │ ├── mock-instance-forgot-reset.ts │ │ └── mock-instance.ts │ │ ├── mock-module │ │ ├── create-resolvers.ts │ │ ├── mark-providers.ts │ │ ├── mock-module.spec.fixtures.ts │ │ ├── mock-module.spec.ts │ │ ├── mock-module.ts │ │ ├── mock-ng-def.ts │ │ ├── providers.spec.ts │ │ └── types.ts │ │ ├── mock-pipe │ │ ├── mock-pipe.spec.ts │ │ ├── mock-pipe.ts │ │ └── types.ts │ │ ├── mock-provider │ │ ├── mock-provider.spec.ts │ │ └── mock-provider.ts │ │ ├── mock-render │ │ ├── func.create-wrapper.ts │ │ ├── func.generate-template.ts │ │ ├── func.install-prop-reader.ts │ │ ├── func.reflect-template.ts │ │ ├── mock-render-factory.ts │ │ ├── mock-render.spec.fixtures.ts │ │ ├── mock-render.spec.ts │ │ ├── mock-render.ts │ │ └── types.ts │ │ ├── mock-service │ │ ├── check.is-class.ts │ │ ├── check.is-func.spec.ts │ │ ├── check.is-func.ts │ │ ├── check.is-inst.ts │ │ ├── helper.create-clone.ts │ │ ├── helper.create-mock-from-prototype.ts │ │ ├── helper.define-property-descriptor.ts │ │ ├── helper.extract-methods-from-prototype.ts │ │ ├── helper.extract-properties-from-prototype.ts │ │ ├── helper.extract-property-descriptor.spec.ts │ │ ├── helper.extract-property-descriptor.ts │ │ ├── helper.mock-function.ts │ │ ├── helper.mock-service.ts │ │ ├── helper.mock.ts │ │ ├── helper.replace-with-mocks.ts │ │ ├── helper.resolve-provider.ts │ │ ├── helper.use-factory.ts │ │ ├── mock-provider.ts │ │ ├── mock-service.spec.ts │ │ ├── mock-service.ts │ │ └── types.ts │ │ ├── mock │ │ ├── clone-providers.ts │ │ ├── decorate-declaration.ts │ │ ├── get-mock.ts │ │ ├── mark-exported.ts │ │ ├── return-cached-mock.ts │ │ ├── to-existing-provider.ts │ │ └── to-factory-provider.ts │ │ └── resolve │ │ ├── collect-declarations.spec.ts │ │ └── collect-declarations.ts │ ├── tsconfig.build.cjs.json │ ├── tsconfig.build.mjs.json │ └── tsconfig.json ├── package-lock.json ├── package.json ├── renovate.json ├── test.sh ├── test.ts ├── tests-e2e ├── .browserslistrc ├── .gitignore ├── .nvmrc ├── angular.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── src │ ├── app │ │ ├── app.component.spec.ts │ │ ├── app.component.ts │ │ ├── app.directive.ts │ │ ├── app.module.ts │ │ ├── app.pipe.ts │ │ └── app.service.ts │ ├── index.html │ ├── issue-10762 │ │ ├── ngx-translate.spec.ts │ │ └── test.spec.ts │ ├── issue-305 │ │ └── test.spec.ts │ ├── issue-312 │ │ ├── import-features.spec.ts │ │ ├── only-feature.spec.ts │ │ └── test.spec.ts │ ├── issue-4249 │ │ └── test.spec.ts │ ├── issue-4344 │ │ └── test.spec.ts │ ├── issue-4693 │ │ ├── child.component.ts │ │ └── test.spec.ts │ ├── issue-488 │ │ └── faster.spec.ts │ ├── issue-5239 │ │ └── test.spec.ts │ ├── issue-589 │ │ ├── dev-tools.spec.ts │ │ └── meta-reducers.spec.ts │ ├── issue-971 │ │ └── test.spec.ts │ ├── main.ts │ ├── mat-input │ │ └── test.spec.ts │ ├── mat-table │ │ ├── e2e.spec.ts │ │ └── test.spec.ts │ ├── ng-select │ │ └── test.spec.ts │ ├── ngrx │ │ └── provide-mock-store.spec.ts │ ├── ngx-translate │ │ └── test.spec.ts │ ├── ngxs │ │ └── test.spec.ts │ ├── p-calendar │ │ └── test.spec.ts │ ├── performance │ │ └── ng-mocks.spec.ts │ ├── spectator │ │ ├── classic.spec.ts │ │ └── standalone.spec.ts │ ├── test.ts │ ├── testing-library │ │ ├── classic.spec.ts │ │ └── standalone.spec.ts │ └── transloco │ │ └── test.spec.ts └── tsconfig.json ├── tests-failures ├── get-mocked-ng-def-of.ts ├── mock-builder-constructor.ts ├── mock-builder-exclude.ts ├── mock-builder-keep.ts ├── mock-builder-mock.ts ├── mock-builder-provide.ts ├── mock-builder-replace.ts ├── mock-component.ts ├── mock-directive.ts ├── mock-instance-members.ts ├── mock-instance-service.ts ├── mock-instance-token.ts ├── mock-module.ts ├── mock-pipe.ts ├── mock-provider.ts ├── mock-render-string.ts ├── mock-render-token.ts ├── mock-render-type.ts ├── mock-service.ts └── ng-mocks-stub.ts ├── tests-performance ├── mock-builder.spec.ts ├── mock-render.spec.ts ├── test-bed.spec.ts └── test.spec.ts ├── tests ├── NG_MOCKS_ROOT_PROVIDERS │ └── test.spec.ts ├── abstract-methods-provider │ └── test.spec.ts ├── auto-spy │ └── test.spec.ts ├── context-with-directives │ ├── fixtures.ts │ └── test.spec.ts ├── control-value-accessor-form-control │ └── test.spec.ts ├── control-value-accessor-ng-model │ └── test.spec.ts ├── correct-module-exports │ └── test.spec.ts ├── double-declarations │ ├── fixtures.ts │ └── test.spec.ts ├── double-decorator │ ├── example-1.spec.ts │ ├── example-2.spec.ts │ ├── example-3.spec.ts │ ├── with-selector.spec.ts │ ├── without-selector-ivy.spec.ts │ └── without-selector.spec.ts ├── export-all │ └── test.spec.ts ├── exports-only │ └── test.spec.ts ├── fake-async │ └── test.spec.ts ├── flex-exact-mocks │ └── test.spec.ts ├── get-inputs-and-outputs │ ├── fixtures.ts │ └── test.spec.ts ├── get-mocked-ng-def-of │ └── test.spec.ts ├── injected-ng-templates │ ├── fixtures.ts │ └── test.spec.ts ├── interceptor-kept-mocked │ └── test.spec.ts ├── internal-only-nested │ └── test.spec.ts ├── internal-only │ └── test.spec.ts ├── internal-vs-external │ └── test.spec.ts ├── is-mock-of │ └── test.spec.ts ├── is-mocked-ng-def-of │ └── test.spec.ts ├── issue-10020 │ └── errors.spec.ts ├── issue-10306 │ └── test.spec.ts ├── issue-11324 │ └── test.spec.ts ├── issue-1165 │ └── test.spec.ts ├── issue-1168 │ └── test.spec.ts ├── issue-1256 │ └── test.spec.ts ├── issue-1377 │ └── test.spec.ts ├── issue-142 │ └── test.spec.ts ├── issue-1427 │ └── test.spec.ts ├── issue-145 │ ├── components.spec.ts │ └── directives.spec.ts ├── issue-1507 │ └── test.spec.ts ├── issue-151 │ ├── app │ │ ├── app-routing.module.ts │ │ ├── app.component.ts │ │ ├── app.module.ts │ │ ├── hello.component.ts │ │ └── hello.module.ts │ └── test.spec.ts ├── issue-157 │ └── test.spec.ts ├── issue-1587 │ └── test.spec.ts ├── issue-1596 │ └── test.spec.ts ├── issue-162 │ └── test.spec.ts ├── issue-166 │ └── test.spec.ts ├── issue-167 │ ├── component.spec.ts │ ├── directive.spec.ts │ └── ng-validators.spec.ts ├── issue-170 │ └── test.spec.ts ├── issue-172 │ └── test.spec.ts ├── issue-173 │ └── test.spec.ts ├── issue-175 │ ├── fixtures.ts │ └── test.spec.ts ├── issue-177 │ └── test.spec.ts ├── issue-178 │ └── test.spec.ts ├── issue-181 │ └── test.spec.ts ├── issue-186 │ └── test.spec.ts ├── issue-1876 │ └── test.spec.ts ├── issue-1957 │ └── test.spec.ts ├── issue-197 │ ├── abstract.spec.ts │ └── with-providers.spec.ts ├── issue-2087 │ └── test.spec.ts ├── issue-2097 │ ├── nested.spec.ts │ └── test.spec.ts ├── issue-2105 │ └── test.spec.ts ├── issue-218 │ └── test.spec.ts ├── issue-222 │ ├── app-initializer.spec.ts │ ├── application-module.spec.ts │ ├── common-module.spec.ts │ ├── dom-shared-styles-host.spec.ts │ ├── injector-scope.spec.ts │ ├── injector.spec.ts │ ├── kept-root-injection.spec.ts │ └── mock-keep-priorities.spec.ts ├── issue-2302 │ └── test.spec.ts ├── issue-2311 │ └── test.spec.ts ├── issue-2314 │ └── test.spec.ts ├── issue-2398 │ └── test.spec.ts ├── issue-240 │ ├── fixtures.ts │ ├── test.builder.spec.ts │ ├── test.classic.spec.ts │ ├── test.guts.spec.ts │ ├── test.nodes.spec.ts │ └── test.real.spec.ts ├── issue-241 │ ├── fixtures.ts │ ├── test.builder.spec.ts │ ├── test.classic.spec.ts │ ├── test.guts.spec.ts │ └── test.real.spec.ts ├── issue-246 │ └── test.spec.ts ├── issue-248 │ └── test.spec.ts ├── issue-2646 │ └── test.spec.ts ├── issue-2647 │ ├── errors.spec.ts │ ├── ignore.spec.ts │ ├── test.spec.ts │ └── warn.spec.ts ├── issue-266 │ └── test.spec.ts ├── issue-2687 │ ├── legacy.spec.ts │ └── test.spec.ts ├── issue-270 │ └── test.spec.ts ├── issue-271 │ └── test.spec.ts ├── issue-2845 │ └── test.spec.ts ├── issue-288 │ ├── ng-model.spec.ts │ └── test.spec.ts ├── issue-289 │ └── test.spec.ts ├── issue-296 │ └── test.spec.ts ├── issue-298 │ ├── case.spec.ts │ ├── pipes.spec.ts │ ├── stack-blitz.spec.ts │ └── test.spec.ts ├── issue-302 │ └── test.spec.ts ├── issue-305 │ ├── forms.spec.ts │ ├── overrides.spec.ts │ └── reactive-forms.spec.ts ├── issue-3053 │ └── test.spec.ts ├── issue-3095 │ └── test.spec.ts ├── issue-3100 │ └── test.spec.ts ├── issue-312 │ └── test.spec.ts ├── issue-3161 │ ├── exclude.spec.ts │ ├── keep.spec.ts │ └── test.spec.ts ├── issue-3265 │ └── test.spec.ts ├── issue-3274 │ └── test.spec.ts ├── issue-333 │ └── test.spec.ts ├── issue-354 │ └── test.spec.ts ├── issue-3635 │ └── test.spec.ts ├── issue-3636 │ └── test.spec.ts ├── issue-377 │ ├── e2e.spec.ts │ └── test.spec.ts ├── issue-3791 │ └── test.spec.ts ├── issue-3811 │ └── test.spec.ts ├── issue-4032 │ └── test.spec.ts ├── issue-4228 │ └── test.spec.ts ├── issue-4282 │ ├── global.spec.ts │ └── test.spec.ts ├── issue-434 │ └── test.spec.ts ├── issue-4344 │ ├── standalone-explicit.spec.ts │ ├── standalone.spec.ts │ ├── test.spec.ts │ ├── with-providers-explicit.spec.ts │ └── with-providers.spec.ts ├── issue-435 │ └── test.spec.ts ├── issue-4367 │ └── test.spec.ts ├── issue-445 │ └── test.spec.ts ├── issue-455 │ ├── abstract.spec.ts │ └── token.spec.ts ├── issue-4564 │ └── test.spec.ts ├── issue-4613 │ ├── providers.spec.ts │ └── test.spec.ts ├── issue-4641 │ ├── mixed.spec.ts │ └── test.spec.ts ├── issue-488 │ ├── faster.spec.ts │ └── test.spec.ts ├── issue-5047 │ └── test.spec.ts ├── issue-5117 │ ├── base.spec.ts │ ├── coverage.spec.ts │ ├── input.spec.ts │ ├── output.spec.ts │ └── test.spec.ts ├── issue-522 │ └── test.spec.ts ├── issue-5239 │ └── test.spec.ts ├── issue-5262 │ └── test.spec.ts ├── issue-5350 │ └── test.spec.ts ├── issue-537 │ └── test.spec.ts ├── issue-538 │ └── test.spec.ts ├── issue-5417 │ └── test.spec.ts ├── issue-5465 │ └── test.spec.ts ├── issue-5520 │ └── test.spec.ts ├── issue-5537 │ └── test.spec.ts ├── issue-567 │ └── test.spec.ts ├── issue-568 │ └── test.spec.ts ├── issue-572 │ └── test.spec.ts ├── issue-576 │ └── test.spec.ts ├── issue-589 │ └── test.spec.ts ├── issue-621 │ └── test.spec.ts ├── issue-623 │ ├── nested.spec.ts │ └── test.spec.ts ├── issue-625 │ └── test.spec.ts ├── issue-6402 │ └── test.spec.ts ├── issue-641 │ └── test.spec.ts ├── issue-6928 │ └── test.spec.ts ├── issue-7041 │ └── test.spec.ts ├── issue-721 │ ├── before-all.spec.ts │ └── before-each.spec.ts ├── issue-7216 │ └── test.spec.ts ├── issue-726 │ └── test.spec.ts ├── issue-735 │ ├── date-pipe.spec.ts │ ├── provider-for-module.spec.ts │ ├── provider.spec.ts │ ├── test.spec.ts │ ├── token-for-root.spec.ts │ └── token.spec.ts ├── issue-736 │ └── test.spec.ts ├── issue-760 │ ├── jest.spec.ts │ └── no-decorators.spec.ts ├── issue-762 │ ├── module.spec.ts │ ├── string.spec.ts │ └── token.spec.ts ├── issue-7796 │ └── test.spec.ts ├── issue-857 │ └── string.spec.ts ├── issue-885 │ └── test.spec.ts ├── issue-8884 │ └── test.spec.ts ├── issue-919 │ └── test.spec.ts ├── issue-971 │ └── test.spec.ts ├── mock-builder-by-directive │ └── test.spec.ts ├── mock-builder-keeps-application-module │ ├── fixtures.ts │ └── test.spec.ts ├── mock-builder-use-class │ └── 599.spec.ts ├── mock-component-render │ ├── content-child.spec.ts │ ├── content-children-groups.spec.ts │ ├── content-children.spec.ts │ ├── hide.spec.ts │ └── reduced.spec.ts ├── mock-component │ └── test.spec.ts ├── mock-directive-with-multi-token │ └── test.spec.ts ├── mock-helper-flush-test-bed │ └── test.spec.ts ├── mock-instance-in-it │ └── test.spec.ts ├── mock-instance-member │ ├── reset.spec.ts │ └── test.spec.ts ├── mock-instance-scope │ └── test.spec.ts ├── mock-instance-token │ └── test.spec.ts ├── mock-of-mock │ └── test.spec.ts ├── mock-provider │ └── 599.spect.ts ├── mock-render-all-properties │ └── test.spec.ts ├── mock-render-attribute │ └── test.spec.ts ├── mock-render-factory │ ├── docs.spec.ts │ ├── install.spec.ts │ ├── test.spec.ts │ └── tpl.spec.ts ├── mock-render-mirrors-component │ └── test.spec.ts ├── mock-render-param-ref │ └── test.spec.ts ├── mock-render-tokens │ └── test.spec.ts ├── mock-render-view-providers │ └── test.spec.ts ├── mock-service-override │ └── test.spec.ts ├── mock-service │ ├── observable.spec.ts │ └── test.spec.ts ├── module-with-factory-tokens │ └── test.spec.ts ├── module-with-tokens │ └── test.spec.ts ├── multi-tokens │ └── test.spec.ts ├── nested-before-each │ └── test.spec.ts ├── ng-mocks-change │ ├── 317.spec.ts │ ├── 3341.spec.ts │ ├── cdr-change.spec.ts │ ├── cdr-input.spec.ts │ ├── forms.spec.ts │ └── reactive-forms.spec.ts ├── ng-mocks-click │ └── 317.spec.ts ├── ng-mocks-crawl │ ├── 317.spec.ts │ └── test.spec.ts ├── ng-mocks-default-mock │ ├── fixtures.ts │ ├── test.builder.spec.ts │ ├── test.guts.spec.ts │ ├── test.precise.spec.ts │ ├── test.real.spec.ts │ └── test.unset.spec.ts ├── ng-mocks-faster │ └── test.spec.ts ├── ng-mocks-find-all │ └── test.spec.ts ├── ng-mocks-find-instance-token │ └── test.spec.ts ├── ng-mocks-find-instance │ ├── 317.spec.ts │ ├── abstract.spec.ts │ └── test.spec.ts ├── ng-mocks-find-instances │ ├── 317.spec.ts │ └── test.spec.ts ├── ng-mocks-find-template-ref │ ├── 317.spec.ts │ └── test.spec.ts ├── ng-mocks-find-template-refs │ ├── 317.spec.ts │ └── test.spec.ts ├── ng-mocks-find │ └── test.spec.ts ├── ng-mocks-format-html │ └── test.spec.ts ├── ng-mocks-format-text │ └── test.spec.ts ├── ng-mocks-get │ ├── 317.spec.ts │ └── test.spec.ts ├── ng-mocks-global-exclude-modules │ └── test.spec.ts ├── ng-mocks-global-exclude │ ├── test.override.spec.ts │ └── test.spec.ts ├── ng-mocks-global-keep-modules │ └── test.spec.ts ├── ng-mocks-global-keep │ ├── test.override.spec.ts │ └── test.spec.ts ├── ng-mocks-global-mock │ └── test.spec.ts ├── ng-mocks-global-replace-modules │ └── test.spec.ts ├── ng-mocks-global-replace │ ├── test.component.spec.ts │ ├── test.directive.spec.ts │ ├── test.failures.spec.ts │ ├── test.override.spec.ts │ └── test.pipe.spec.ts ├── ng-mocks-global-wipe │ └── test.spec.ts ├── ng-mocks-ignore-on-console │ └── test.spec.ts ├── ng-mocks-input │ └── 317.spec.ts ├── ng-mocks-output │ └── 317.spec.ts ├── ng-mocks-render │ ├── cdr.spec.ts │ ├── component.spec.ts │ ├── debug-node.spec.ts │ ├── directive.spec.ts │ ├── idea.spec.ts │ ├── parameters.spec.ts │ └── use-existing.spec.ts ├── ng-mocks-reveal-all │ └── 317.spec.ts ├── ng-mocks-reveal │ ├── 317.spec.ts │ └── test.spec.ts ├── ng-mocks-search-with-no-fixture │ ├── fixtures.ts │ ├── test.fixture.spec.ts │ └── test.no-fixture.spec.ts ├── ng-mocks-stub-member │ └── test.spec.ts ├── ng-mocks-stub │ └── test.spec.ts ├── ng-mocks-throw-on-console │ └── test.spec.ts ├── ng-mocks-touch │ ├── 317.spec.ts │ ├── 3341.spec.ts │ ├── cdr-blur.spec.ts │ ├── cdr-touch.spec.ts │ └── test.spec.ts ├── ng-mocks-trigger │ ├── 317.spec.ts │ ├── blur.spec.ts │ ├── click.spec.ts │ ├── focus.spec.ts │ ├── keyup.spec.ts │ └── test.spec.ts ├── ng-zone │ └── test.spec.ts ├── normal-usage-after-mock-builder │ └── test.spec.ts ├── on-push │ └── on-push.spec.ts ├── performance │ └── test.spec.ts ├── pipe-as-service │ └── test.spec.ts ├── pipe-auto-spy │ └── test.spec.ts ├── providedin-root │ └── test.spec.ts ├── provider-never-mock │ └── test.spec.ts ├── provider-with-custom-dependencies │ └── test.spec.ts ├── provider-with-dependency │ └── test.spec.ts ├── replace-service-wherever │ └── test.spec.ts ├── rerender-rendered-content-child │ ├── fixtures.ts │ └── test.spec.ts ├── root-provider-in-depths │ └── test.spec.ts ├── root-provider-with-root-dep │ └── test.spec.ts ├── root-provider-with-string-dep │ └── test.spec.ts ├── root-providers │ └── test.spec.ts ├── shared-mocked-module │ ├── fixtures.ts │ └── test.spec.ts ├── spies │ └── test.spec.ts ├── structural-directives │ ├── spec.custom-ng-for-with-of.directive.fixtures.ts │ ├── spec.custom-ng-for-without-of.directive.fixtures.ts │ ├── spec.custom-ng-if.directive.fixtures.ts │ └── test.spec.ts ├── tokens-class │ └── test.spec.ts ├── tokens-existing │ └── test.spec.ts ├── tokens-factory │ └── test.spec.ts └── tokens-value │ └── test.spec.ts ├── tsconfig.json ├── tslint.json └── webpack.config.js /.commitlintrc.yml: -------------------------------------------------------------------------------- 1 | extends: '@commitlint/config-conventional' 2 | rules: 3 | body-max-line-length: 4 | - 2 5 | - always 6 | - Infinity 7 | subject-case: 8 | - 0 9 | - always 10 | - lower-case 11 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /docs/node_modules 3 | /e2e/a5es5/node_modules 4 | /e2e/a5es2015/node_modules 5 | /e2e/a6/node_modules 6 | /e2e/a7/node_modules 7 | /e2e/a8/node_modules 8 | /e2e/a9/node_modules 9 | /e2e/a10/node_modules 10 | /e2e/a11/node_modules 11 | /e2e/a12/node_modules 12 | /e2e/a13/node_modules 13 | /e2e/a14/node_modules 14 | /e2e/a15/node_modules 15 | /e2e/a16/node_modules 16 | /e2e/a17/node_modules 17 | /e2e/a18/node_modules 18 | /e2e/a19/node_modules 19 | /e2e/a20/node_modules 20 | /e2e/jasmine/node_modules 21 | /e2e/jest/node_modules 22 | /e2e/min/node_modules 23 | /e2e/mx/node_modules 24 | /node_modules 25 | /test-reports 26 | /tmp 27 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 2 8 | indent_style = space 9 | insert_final_newline = true 10 | max_line_length = 120 11 | tab_width = 2 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | 17 | [README.md] 18 | max_line_length = 50 19 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | .dockerignore 2 | .eslintignore 3 | .gitignore 4 | .prettierignore 5 | CHANGELOG.md 6 | CODEOWNERS 7 | renovate.json 8 | 9 | dist/ 10 | docs/.docusaurus 11 | docs/articles/**/*.md 12 | docs/src/css 13 | e2e/*/.angular 14 | e2e/*/src/app 15 | e2e/*/src/test 16 | node_modules/ 17 | test-reports/ 18 | tests-e2e/.angular 19 | tests-failures/ 20 | tmp/ 21 | 22 | **/*.sh 23 | **/*.snap 24 | **/.nvmrc 25 | **/.browserslistrc 26 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: help-me-mom 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Ask help on Stackoverflow 4 | about: In case if you have a well defined question or clear expectations with prepared code examples 5 | url: https://stackoverflow.com/questions/ask?tags=ng-mocks%20angular%20testing%20mocking 6 | - name: Ask a question 7 | about: In case if you DO NOT have a well defined question 8 | url: https://github.com/help-me-mom/ng-mocks/discussions/new 9 | - name: Chat on gitter 10 | about: A good place for quick questions 11 | url: https://gitter.im/ng-mocks/community 12 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: Use this template for feature requests. 4 | title: 'Feature Request: ' 5 | labels: enhancement 6 | --- 7 | 8 | ### Describe the feature or problem you'd like to solve 9 | 10 | 11 | 12 | ### Proposed solution 13 | 14 | 15 | 16 | ### Additional context 17 | 18 | 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .angular 3 | .env 4 | .idea 5 | .nx 6 | /dist 7 | /node_modules 8 | /test-reports 9 | /tmp 10 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | npx commitlint --edit $1 2 | -------------------------------------------------------------------------------- /.husky/post-commit: -------------------------------------------------------------------------------- 1 | git update-index --again 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | npx lint-staged 2 | npm run lint 3 | npm run ts:check 4 | -------------------------------------------------------------------------------- /.husky/pre-push: -------------------------------------------------------------------------------- 1 | npm run test 2 | -------------------------------------------------------------------------------- /.lintstagedrc.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | '*': filenames => { 5 | const commands = []; 6 | const cwd = process.cwd(); 7 | const files = filenames.map(file => path.relative(cwd, file)).map(file => `'${file}'`); 8 | if (files.length === 0) { 9 | return []; 10 | } 11 | 12 | commands.push(`prettier -w ${files.join(' ')}`); 13 | commands.push(`eslint --fix ${files.join(' ')}`); 14 | 15 | return commands; 16 | }, 17 | }; 18 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .browserslistrc 2 | .dockerignore 3 | .eslintignore 4 | .gitignore 5 | .prettierignore 6 | CHANGELOG.md 7 | CODEOWNERS 8 | renovate.json 9 | 10 | .husky/ 11 | dist/ 12 | docs/**/*.md 13 | docs/.docusaurus 14 | e2e/*/.angular 15 | e2e/*/src/app 16 | e2e/*/src/test 17 | e2e/nx/apps/*/src/app 18 | e2e/nx/apps/*/src/test 19 | node_modules/ 20 | test-reports/ 21 | tests-e2e/.angular 22 | tmp/ 23 | 24 | **/*.sh 25 | **/*.snap 26 | **/.nvmrc 27 | -------------------------------------------------------------------------------- /.prettierrc.yml: -------------------------------------------------------------------------------- 1 | arrowParens: 'avoid' 2 | bracketSpacing: true 3 | endOfLine: 'lf' 4 | jsxSingleQuote: true 5 | printWidth: 120 6 | proseWrap: 'preserve' 7 | semi: true 8 | singleQuote: true 9 | tabWidth: 2 10 | trailingComma: 'all' 11 | useTabs: false 12 | overrides: 13 | - files: 'README.md' 14 | options: 15 | printWidth: 50 16 | - files: '*.spec.ts' 17 | options: 18 | printWidth: 70 19 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This is a comment. 2 | # Each line is a file pattern followed by one or more owners. 3 | * @satanTime 4 | 5 | **/.nvmrc 6 | **/compose.yml 7 | **/package.json 8 | **/package-lock.json 9 | 10 | /.circleci/config.yml 11 | /.github/workflows/codeql.yml 12 | 13 | /libs/ng-mocks/package.json @satanTime 14 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | /.docusaurus 2 | /node_modules 3 | -------------------------------------------------------------------------------- /docs/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /docs/articles/api/helpers/getSourceOfMock.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: getSourceOfMock 3 | description: Documentation about getSourceOfMock from ng-mocks library 4 | --- 5 | 6 | `getSourceOfMock` returns the origin of a mock class. 7 | 8 | ```ts 9 | // returns the source class of `MockClass` 10 | const OriginalClass1 = getSourceOfMock(MockClass); 11 | 12 | // returns the same class if OriginalClass2 is not a mock 13 | const OriginalClass2 = getSourceOfMock(OriginalClass2); 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/articles/api/helpers/isNgDef.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: isNgDef 3 | description: Documentation about isNgDef from ng-mocks library 4 | --- 5 | 6 | `isNgDef` verifies how a class has been decorated. 7 | 8 | ```ts 9 | if (isNgDef(SomeClass, 'm')) { 10 | // SomeClass is a module 11 | } 12 | 13 | if (isNgDef(SomeClass, 'c')) { 14 | // SomeClass is a component 15 | } 16 | 17 | if (isNgDef(SomeClass, 'd')) { 18 | // SomeClass is a directive 19 | } 20 | 21 | if (isNgDef(SomeClass, 'p')) { 22 | // SomeClass is a pipe 23 | } 24 | 25 | if (isNgDef(SomeClass, 'i')) { 26 | // SomeClass is a service 27 | } 28 | 29 | if (isNgDef(SomeClass, 't')) { 30 | // SomeClass is a token 31 | } 32 | 33 | if (isNgDef(SomeClass)) { 34 | // SomeClass is a module or component or directive or pipe or service 35 | } 36 | ``` 37 | -------------------------------------------------------------------------------- /docs/articles/api/helpers/isNgInjectionToken.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: isNgInjectionToken 3 | description: Documentation about isNgInjectionToken from ng-mocks library 4 | --- 5 | 6 | `isNgInjectionToken` verifies whether an object is a token. 7 | 8 | ```ts 9 | if (isNgInjectionToken(TOKEN)) { 10 | // do something 11 | } 12 | ``` 13 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/event.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.event 3 | description: Documentation about `ngMocks.event`, a simple interface to create custom events in unit tests 4 | --- 5 | 6 | `ngMocks.event` solves the legacy of IE11, when an event object cannot be created via `new CustomEvent`, but via `document.createEvent`. 7 | 8 | Besides that, `ngMocks.event` provides a simple interface to customize the event properties. 9 | 10 | ```ts 11 | const event = ngMocks.event('click', { 12 | x: 1, 13 | y: 2, 14 | }); 15 | ``` 16 | 17 | The created event can be dispatched via [`ngMocks.trigger`](trigger.md#custom-events). 18 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/flushTestBed.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.flushTestBed 3 | description: Documentation about ngMocks.flushTestBed from ng-mocks library 4 | --- 5 | 6 | `ngMocks.flushTestBed` flushes initialization of TestBed. 7 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/globalKeep.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.globalKeep 3 | description: Documentation about ngMocks.globalKeep from ng-mocks library 4 | --- 5 | 6 | `ngMocks.globalKeep` marks declarations, services and tokens to be avoided from the mocking process during creating mock modules. 7 | 8 | The best place to do that is in `src/test.ts` for `jasmine` or in `src/setup-jest.ts` / `src/test-setup.ts` for `jest`. 9 | 10 | Let's mark the `APP_URL` token in order to be kept in mock modules. 11 | 12 | ```ts title="src/test.ts" 13 | ngMocks.globalKeep(APP_URL); 14 | ``` 15 | 16 | ```ts title="src/test.spec.ts" 17 | // ... 18 | MockModule(ModuleWithService); 19 | // ... 20 | const url = TestBed.inject(APP_URL); 21 | // ... 22 | ``` 23 | 24 | The `url` is the original one. 25 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/globalReplace.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.globalReplace 3 | description: Documentation about ngMocks.globalReplace from ng-mocks library 4 | --- 5 | 6 | `ngMocks.globalReplace` marks declarations and modules (but not services and tokens) to be replaced during creating mock modules. 7 | 8 | The best place to do that is in `src/test.ts` for `jasmine` or in `src/setup-jest.ts` / `src/test-setup.ts` for `jest`. 9 | 10 | If we wanted to replace `BrowserAnimationsModule` with `NoopAnimationsModule` globally, 11 | we could do it like that: 12 | 13 | ```ts title="src/test.ts" 14 | ngMocks.globalReplace(BrowserAnimationsModule, NoopAnimationsModule); 15 | ``` 16 | 17 | Now, all mock modules which import `BrowserAnimationsModule` have `NoopAnimationsModule` instead. 18 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/globalWipe.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.globalWipe 3 | description: Documentation about ngMocks.globalWipe from ng-mocks library 4 | --- 5 | 6 | `ngMocks.globalWipe` resets all customizations which have been done by any `ngMocks.default` function. 7 | 8 | ```ts 9 | ngMocks.defaultMock(Service, () => ({ 10 | stream$: EMPTY, 11 | })); 12 | ngMocks.globalExclude(Component); 13 | ngMocks.globalKeep(Directive); 14 | ngMocks.globalReplace(Pipe, FakePipe); 15 | 16 | ngMocks.globalWipe(Service); 17 | ngMocks.globalWipe(Component); 18 | ngMocks.globalWipe(Directive); 19 | ngMocks.globalWipe(Pipe); 20 | 21 | // All the things above will be mocked as usual 22 | ``` 23 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/ignoreOnConsole.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.ignoreOnConsole 3 | description: A way to suppress console logs in Angular unit tests 4 | --- 5 | 6 | `ngMocks.ignoreOnConsole` suppresses `console.log` with a spy (if [auto spy](/extra/auto-spy.md) is being used). 7 | 8 | `ngMocks.ignoreOnConsole` suppresses the functions for the current test suite in `beforeAll` and restores in `afterAll`. 9 | 10 | Also, any other methods can be stubbed: 11 | 12 | ```ts 13 | ngMocks.ignoreOnConsole('log', 'err', 'warn'); 14 | ``` 15 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/input.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.input 3 | description: Documentation about `ngMocks.input` from ng-mocks library 4 | --- 5 | 6 | Returns value of an `input` of an element. 7 | It avoids the issue of knowing the name of a component / directive the input belongs to. 8 | 9 | - `ngMocks.input( debugElement, input, notFoundValue? )` 10 | 11 | or simply with selectors which are supported by [`ngMocks.find`](find.md). 12 | 13 | - `ngMocks.input( cssSelector, input, notFoundValue? )` 14 | 15 | ```ts 16 | const inputValue = ngMocks.input(debugElement, 'param1'); 17 | ``` 18 | ```ts 19 | const inputValue = ngMocks.input('app-component', 'param1'); 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/output.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.output 3 | description: Documentation about `ngMocks.output` from ng-mocks library 4 | --- 5 | 6 | Returns an emitter of an `output` of an element. 7 | It avoids the issue of knowing the name of a component / directive the output belongs to. 8 | 9 | - `ngMocks.output( debugElement, output, notFoundValue? )` 10 | 11 | or simply with selectors which are supported by [`ngMocks.find`](find.md). 12 | 13 | - `ngMocks.output( cssSelector, output, notFoundValue? )` 14 | 15 | ```ts 16 | const outputEmitter = ngMocks.output(debugElement, 'update'); 17 | ``` 18 | ```ts 19 | const outputEmitter = ngMocks.output('app-component', 'update'); 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/reset.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.reset 3 | description: Documentation about `ngMocks.reset` from ng-mocks library 4 | --- 5 | 6 | `ngMocks.reset` resets cache of `ng-mocks`. 7 | -------------------------------------------------------------------------------- /docs/articles/api/ngMocks/throwOnConsole.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: ngMocks.throwOnConsole 3 | description: Documentation about ngMocks.throwOnConsole from ng-mocks library 4 | --- 5 | 6 | `ngMocks.throwOnConsole` stubs `console.warn` and `console.error` to throw an error instead of printing it into the console. 7 | It is useful in `Ivy` enabled mode, because some errors are printed via `console` instead of being thrown. 8 | 9 | `ngMocks.throwOnConsole` stubs the functions for the current test suite in `beforeAll` and restores in `afterAll`. 10 | 11 | Also, any other methods can be stubbed: 12 | 13 | ```ts 14 | ngMocks.throwOnConsole('log'); 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/articles/credits.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Valuable people who helped to improve ng-mocks 3 | description: A list of people who provided valuable feedback / contribution to ng-mocks 4 | sidebar_label: Credits 5 | --- 6 | 7 | *Cannot find yourself in the list? Simply click "edit this page" below.* 8 | 9 | ## Maintainers 10 | 11 | - [Isaac Datlof](https://www.linkedin.com/in/isaac-datlof/) 12 | - [Michael Gusev](https://www.linkedin.com/in/michael-gusev/) 13 | 14 | ## Supporters 15 | 16 | - [DmitryEfimenko](https://github.com/DmitryEfimenko) 17 | provided valuable feedback and ideas on how to improve the library 18 | - [Vinay Kaparthi](https://www.linkedin.com/in/vinay-kaparthi/) 19 | provided valuable feedback about performance of the library and shed light on some bottlenecks. 20 | -------------------------------------------------------------------------------- /docs/articles/guides.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How to test an Angular application 3 | description: Guides and examples on how to test an Angular application 4 | sidebar_label: Testing of Angular application 5 | --- 6 | 7 | The goal of this section is to demonstrate **comprehensive examples of angular unit tests** 8 | covering almost all possible cases. 9 | 10 | Please check the side menu for covered cases. 11 | Every page contains explanation, and a **live example** to play with. 12 | 13 | Should you not find an example you are interested in? 14 | Simply [contact us](need-help.md) and describe the desired case. 15 | -------------------------------------------------------------------------------- /docs/articles/need-help.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Find an issue or have a question or a request? 3 | description: Information on how to contact ng-mocks maintainers 4 | sidebar_label: Need help? 5 | --- 6 | 7 | We are open to contributions. 8 | 9 | - [start a discussion on GitHub](https://github.com/help-me-mom/ng-mocks/discussions/new/choose) 10 | - [ask a question on Stackoverflow](https://stackoverflow.com/questions/ask?tags=ng-mocks%20angular%20testing%20mocking) 11 | - [report an issue on GitHub](https://github.com/help-me-mom/ng-mocks/issues) 12 | - [chat on gitter](https://gitter.im/ng-mocks/community) 13 | -------------------------------------------------------------------------------- /docs/articles/tl-dr.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: How to read this 3 | description: Brief summary of how to read the documentation about ng-mocks 4 | --- 5 | 6 | **Essential** 7 | 8 | 1. Read titles from **TOC** 9 | 1. Read the [quick start](extra/quick-start.md) 10 | 1. Read the [how to write tests](extra/how-to-write-tests.md) 11 | 1. Check the [extensive example](extra/extensive-example.md) 12 | 13 | **TL;DR** 14 | 15 | - Read about [MockRender](api/MockRender.md) and [MockInstance](api/MockInstance.md) 16 | - Read about [MockBuilder](api/MockBuilder.md) and [ngMocks](api/ngMocks.md) 17 | - Check [guides and examples how to test Angular applications](guides.md) 18 | -------------------------------------------------------------------------------- /docs/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [require.resolve('@docusaurus/core/lib/babel/preset')], 3 | }; 4 | -------------------------------------------------------------------------------- /docs/static/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/help-me-mom/ng-mocks/71e74bd39a5685b03c44f3286afd7a129f38cb3b/docs/static/.nojekyll -------------------------------------------------------------------------------- /docs/static/img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/help-me-mom/ng-mocks/71e74bd39a5685b03c44f3286afd7a129f38cb3b/docs/static/img/favicon.ico -------------------------------------------------------------------------------- /docs/static/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Allow: / 3 | 4 | Sitemap: https://ng-mocks.sudo.eu/sitemap.xml 5 | -------------------------------------------------------------------------------- /e2e/a10/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major version 15 | last 2 iOS major versions 16 | Firefox ESR 17 | IE 9-11 18 | -------------------------------------------------------------------------------- /e2e/a10/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a10/.nvmrc: -------------------------------------------------------------------------------- 1 | 12.22.12 2 | -------------------------------------------------------------------------------- /e2e/a10/jest.es2015ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es2015ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a10/jest.es2015noivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es2015noivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a10/jest.es5ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es5ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a10/jest.es5noivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es5noivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a10/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a10/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A10 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a10/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a10/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a10/tsconfig.es2015ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2015" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a10/tsconfig.es2015noivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2015" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a10/tsconfig.es5ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a10/tsconfig.es5noivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a10/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "module": "esnext", 13 | "lib": ["es2018", "dom"], 14 | "emitDecoratorMetadata": true, 15 | "esModuleInterop": true, 16 | "skipLibCheck": true, 17 | "types": ["jasmine", "jest", "node"] 18 | }, 19 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 20 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 21 | } 22 | -------------------------------------------------------------------------------- /e2e/a11/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /e2e/a11/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a11/.nvmrc: -------------------------------------------------------------------------------- 1 | 12.22.12 2 | -------------------------------------------------------------------------------- /e2e/a11/jest.es2015ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es2015ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a11/jest.es2015noivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es2015noivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a11/jest.es5ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es5ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a11/jest.es5noivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es5noivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a11/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a11/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A11 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a11/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a11/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a11/tsconfig.es2015ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2020" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a11/tsconfig.es2015noivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2019" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a11/tsconfig.es5ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a11/tsconfig.es5noivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a11/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "module": "esnext", 13 | "lib": ["es2018", "dom"], 14 | "emitDecoratorMetadata": true, 15 | "esModuleInterop": true, 16 | "skipLibCheck": true, 17 | "types": ["jasmine", "jest", "node"] 18 | }, 19 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 20 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 21 | } 22 | -------------------------------------------------------------------------------- /e2e/a12/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | IE 11 18 | -------------------------------------------------------------------------------- /e2e/a12/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a12/.nvmrc: -------------------------------------------------------------------------------- 1 | 12.22.12 2 | -------------------------------------------------------------------------------- /e2e/a12/jest.es2015ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | maxWorkers: 1, 4 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 5 | testURL: 'http://localhost', 6 | testMatch: ['/src/**/*.spec.ts'], 7 | globals: { 8 | 'ts-jest': { 9 | tsconfig: 'tsconfig.es2015ivy.spec.json', 10 | }, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /e2e/a12/jest.es5ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | maxWorkers: 1, 4 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 5 | testURL: 'http://localhost', 6 | testMatch: ['/src/**/*.spec.ts'], 7 | globals: { 8 | 'ts-jest': { 9 | tsconfig: 'tsconfig.es5ivy.spec.json', 10 | }, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /e2e/a12/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a12/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A12 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a12/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a12/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular/setup-jest'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a12/tsconfig.es2015ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2020" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a12/tsconfig.es5ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a13/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /e2e/a13/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a13/.nvmrc: -------------------------------------------------------------------------------- 1 | 12.22.12 2 | -------------------------------------------------------------------------------- /e2e/a13/jest.es2015ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es2015ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a13/jest.es5ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsconfig: 'tsconfig.es5ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a13/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a13/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A13 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a13/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a13/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular/setup-jest'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a13/tsconfig.es2015ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2020" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a13/tsconfig.es5ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a14/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /e2e/a14/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a14/.nvmrc: -------------------------------------------------------------------------------- 1 | 16.20.2 2 | -------------------------------------------------------------------------------- /e2e/a14/jest.es2015ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | globals: { 11 | 'ts-jest': { 12 | tsconfig: 'tsconfig.es2015ivy.spec.json', 13 | }, 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /e2e/a14/jest.es5ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | globals: { 11 | 'ts-jest': { 12 | tsconfig: 'tsconfig.es5ivy.spec.json', 13 | }, 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /e2e/a14/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a14/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A14 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a14/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a14/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": ["src/main.ts", "src/polyfills.ts"], 9 | "include": ["src/**/*.d.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /e2e/a14/tsconfig.es2015ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2020" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a14/tsconfig.es5ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a15/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /e2e/a15/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a15/.nvmrc: -------------------------------------------------------------------------------- 1 | 16.20.2 2 | -------------------------------------------------------------------------------- /e2e/a15/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|mjs|js|html)$': ['jest-preset-angular', { tsconfig: './tsconfig.json' }], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a15/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a15/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A15 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a15/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a16/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /e2e/a16/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a16/.nvmrc: -------------------------------------------------------------------------------- 1 | 18.20.8 2 | -------------------------------------------------------------------------------- /e2e/a16/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|mjs|js|html)$': ['jest-preset-angular', { tsconfig: './tsconfig.json' }], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a16/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a16/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A16 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a16/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | platformBrowserDynamic() 21 | .bootstrapModule(AppModule) 22 | .catch(error => console.error(error)); 23 | -------------------------------------------------------------------------------- /e2e/a17/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a17/.nvmrc: -------------------------------------------------------------------------------- 1 | 20.19.2 2 | -------------------------------------------------------------------------------- /e2e/a17/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|mjs|js|html)$': ['jest-preset-angular', { tsconfig: './tsconfig.json' }], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a17/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a17/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A17 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a17/src/main.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { provideRouter } from '@angular/router'; 3 | 4 | import { AppComponent } from './app/app.component'; 5 | 6 | bootstrapApplication(AppComponent, { 7 | providers: [provideRouter([])], 8 | }).catch(error => console.error(error)); 9 | -------------------------------------------------------------------------------- /e2e/a18/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a18/.nvmrc: -------------------------------------------------------------------------------- 1 | 20.19.2 2 | -------------------------------------------------------------------------------- /e2e/a18/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|mjs|js|html)$': ['jest-preset-angular', { tsconfig: './tsconfig.json' }], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a18/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a18/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A18 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a18/src/main.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { provideRouter } from '@angular/router'; 3 | 4 | import { AppComponent } from './app/app.component'; 5 | 6 | bootstrapApplication(AppComponent, { 7 | providers: [provideRouter([])], 8 | }).catch(error => console.error(error)); 9 | -------------------------------------------------------------------------------- /e2e/a19/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a19/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /e2e/a19/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|mjs|js|html)$': ['jest-preset-angular', { tsconfig: './tsconfig.json' }], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a19/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a19/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A19 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a19/src/main.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { provideRouter } from '@angular/router'; 3 | 4 | import { AppComponent } from './app/app.component'; 5 | 6 | bootstrapApplication(AppComponent, { 7 | providers: [provideRouter([])], 8 | }).catch(error => console.error(error)); 9 | -------------------------------------------------------------------------------- /e2e/a20/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a20/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /e2e/a20/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|mjs|js|html)$': ['jest-preset-angular', { tsconfig: './tsconfig.json' }], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a20/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a20/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A20 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a20/src/main.ts: -------------------------------------------------------------------------------- 1 | import { bootstrapApplication } from '@angular/platform-browser'; 2 | import { provideRouter } from '@angular/router'; 3 | 4 | import { AppComponent } from './app/app.component'; 5 | 6 | bootstrapApplication(AppComponent, { 7 | providers: [provideRouter([])], 8 | }).catch(error => console.error(error)); 9 | -------------------------------------------------------------------------------- /e2e/a5es2015/.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "a5es2015" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "index": "index.html", 11 | "main": "main.ts", 12 | "polyfills": "polyfills.ts", 13 | "test": "test.ts", 14 | "tsconfig": "tsconfig.app.json", 15 | "testTsconfig": "tsconfig.spec.json", 16 | "prefix": "app" 17 | } 18 | ], 19 | "test": { 20 | "karma": { 21 | "config": "./karma.conf.js" 22 | } 23 | }, 24 | "defaults": { 25 | "styleExt": "css", 26 | "component": {} 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /e2e/a5es2015/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a5es2015/.nvmrc: -------------------------------------------------------------------------------- 1 | 8.17.0 2 | -------------------------------------------------------------------------------- /e2e/a5es2015/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": ["@angular/", "rxjs", "zone.js", "core-js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a5es2015/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A5 ES2015 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a5es2015/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a5es2015/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a5es2015/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /e2e/a5es2015/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "emitDecoratorMetadata": true, 8 | "skipLibCheck": true, 9 | "types": ["jasmine", "jest", "node"] 10 | }, 11 | "files": ["test.ts", "polyfills.ts"], 12 | "include": ["**/*.spec.ts", "**/*.d.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /e2e/a5es2015/src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare let module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /e2e/a5es2015/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "module": "es2015", 12 | "target": "es2015", 13 | "lib": ["es2017", "dom"], 14 | "skipLibCheck": true, 15 | "types": ["jasmine", "jest", "node"] 16 | }, 17 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 18 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 19 | } 20 | -------------------------------------------------------------------------------- /e2e/a5es5/.angular-cli.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "project": { 4 | "name": "a5es5" 5 | }, 6 | "apps": [ 7 | { 8 | "root": "src", 9 | "outDir": "dist", 10 | "index": "index.html", 11 | "main": "main.ts", 12 | "polyfills": "polyfills.ts", 13 | "test": "test.ts", 14 | "tsconfig": "tsconfig.app.json", 15 | "testTsconfig": "tsconfig.spec.json", 16 | "prefix": "app" 17 | } 18 | ], 19 | "test": { 20 | "karma": { 21 | "config": "./karma.conf.js" 22 | } 23 | }, 24 | "defaults": { 25 | "styleExt": "css", 26 | "component": {} 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /e2e/a5es5/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a5es5/.nvmrc: -------------------------------------------------------------------------------- 1 | 8.17.0 2 | -------------------------------------------------------------------------------- /e2e/a5es5/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": ["@angular/", "rxjs", "zone.js", "core-js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a5es5/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A5 ES5 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a5es5/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a5es5/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a5es5/src/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json" 3 | } 4 | -------------------------------------------------------------------------------- /e2e/a5es5/src/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "../out-tsc/spec", 5 | "baseUrl": "./", 6 | "module": "commonjs", 7 | "emitDecoratorMetadata": true, 8 | "skipLibCheck": true, 9 | "types": ["jasmine", "jest", "node"] 10 | }, 11 | "files": ["test.ts", "polyfills.ts"], 12 | "include": ["**/*.spec.ts", "**/*.d.ts"] 13 | } 14 | -------------------------------------------------------------------------------- /e2e/a5es5/src/typings.d.ts: -------------------------------------------------------------------------------- 1 | /* SystemJS module definition */ 2 | declare let module: NodeModule; 3 | interface NodeModule { 4 | id: string; 5 | } 6 | -------------------------------------------------------------------------------- /e2e/a5es5/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "module": "es2015", 12 | "target": "es5", 13 | "lib": ["es2017", "dom"], 14 | "skipLibCheck": true, 15 | "types": ["jasmine", "jest", "node"] 16 | }, 17 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 18 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 19 | } 20 | -------------------------------------------------------------------------------- /e2e/a6/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a6/.nvmrc: -------------------------------------------------------------------------------- 1 | 8.17.0 2 | -------------------------------------------------------------------------------- /e2e/a6/jest.es2015.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | setupTestFrameworkScriptFile: '/src/setup-jest.ts', 4 | transform: { 5 | '^.+\\.(ts|js|html)$': 'ts-jest', 6 | }, 7 | 8 | testURL: 'http://localhost', 9 | testMatch: ['/src/**/*.spec.ts'], 10 | globals: { 11 | 'ts-jest': { 12 | tsConfig: 'tsconfig.es2015.spec.json', 13 | }, 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /e2e/a6/jest.es5.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | setupTestFrameworkScriptFile: '/src/setup-jest.ts', 4 | transform: { 5 | '^.+\\.(ts|js|html)$': 'ts-jest', 6 | }, 7 | 8 | testURL: 'http://localhost', 9 | testMatch: ['/src/**/*.spec.ts'], 10 | globals: { 11 | 'ts-jest': { 12 | tsConfig: 'tsconfig.es5.spec.json', 13 | }, 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /e2e/a6/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": ["@angular/", "rxjs", "zone.js", "core-js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a6/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /e2e/a6/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A6 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a6/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a6/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a6/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [true, "attribute", "app", "camelCase"], 5 | "component-selector": [true, "element", "app", "kebab-case"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /e2e/a6/tsconfig.es2015.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es2015" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a6/tsconfig.es5.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a6/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "module": "es2015", 12 | "lib": ["es2017", "dom"], 13 | "esModuleInterop": true, 14 | "skipLibCheck": true, 15 | "types": ["jasmine", "jest", "node"] 16 | }, 17 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 18 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 19 | } 20 | -------------------------------------------------------------------------------- /e2e/a7/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a7/.nvmrc: -------------------------------------------------------------------------------- 1 | 8.17.0 2 | -------------------------------------------------------------------------------- /e2e/a7/jest.es2015.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es2015.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a7/jest.es5.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es5.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a7/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": ["@angular/", "rxjs", "zone.js", "core-js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a7/src/browserslist: -------------------------------------------------------------------------------- 1 | # This file is currently used by autoprefixer to adjust CSS to support the below specified browsers 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | # 5 | # For IE 9-11 support, please remove 'not' from the last line of the file and adjust as needed 6 | 7 | > 0.5% 8 | last 2 versions 9 | Firefox ESR 10 | not dead 11 | not IE 9-11 -------------------------------------------------------------------------------- /e2e/a7/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A7 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a7/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a7/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a7/src/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tslint.json", 3 | "rules": { 4 | "directive-selector": [true, "attribute", "app", "camelCase"], 5 | "component-selector": [true, "element", "app", "kebab-case"] 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /e2e/a7/tsconfig.es2015.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es2015" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a7/tsconfig.es5.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a7/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "moduleResolution": "node", 9 | "emitDecoratorMetadata": true, 10 | "experimentalDecorators": true, 11 | "importHelpers": true, 12 | "module": "es2015", 13 | "lib": ["es2018", "dom"], 14 | "esModuleInterop": true, 15 | "skipLibCheck": true, 16 | "types": ["jasmine", "jest", "node"] 17 | }, 18 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 19 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 20 | } 21 | -------------------------------------------------------------------------------- /e2e/a8/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a8/.nvmrc: -------------------------------------------------------------------------------- 1 | 10.24.1 2 | -------------------------------------------------------------------------------- /e2e/a8/browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. -------------------------------------------------------------------------------- /e2e/a8/jest.es2015.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es2015.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a8/jest.es5.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es5.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a8/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a8/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A8 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a8/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a8/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a8/tsconfig.es2015.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es2015" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a8/tsconfig.es5.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /e2e/a8/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "module": "esnext", 13 | "lib": ["es2018", "dom"], 14 | "emitDecoratorMetadata": true, 15 | "esModuleInterop": true, 16 | "skipLibCheck": true, 17 | "types": ["jasmine", "jest", "node"] 18 | }, 19 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 20 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 21 | } 22 | -------------------------------------------------------------------------------- /e2e/a9/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/a9/.nvmrc: -------------------------------------------------------------------------------- 1 | 12.22.12 2 | -------------------------------------------------------------------------------- /e2e/a9/browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | IE 9-11 13 | -------------------------------------------------------------------------------- /e2e/a9/jest.es2015ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es2015ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a9/jest.es2015noivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es2015noivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a9/jest.es5ivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es5ivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a9/jest.es5noivy.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testURL: 'http://localhost', 7 | testMatch: ['/src/**/*.spec.ts'], 8 | globals: { 9 | 'ts-jest': { 10 | tsConfig: 'tsconfig.es5noivy.spec.json', 11 | }, 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/a9/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "whitelistedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/a9/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | A9 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/a9/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/a9/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import 'jest-preset-angular'; 2 | import { ngMocks } from 'ng-mocks'; 3 | 4 | ngMocks.autoSpy('jest'); 5 | -------------------------------------------------------------------------------- /e2e/a9/tsconfig.es2015ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2016" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a9/tsconfig.es2015noivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "ES2015" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a9/tsconfig.es5ivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a9/tsconfig.es5noivy.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "target": "es5" 5 | }, 6 | "angularCompilerOptions": { 7 | "enableIvy": false 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /e2e/a9/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "downlevelIteration": true, 9 | "experimentalDecorators": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "module": "esnext", 13 | "lib": ["es2018", "dom"], 14 | "emitDecoratorMetadata": true, 15 | "esModuleInterop": true, 16 | "skipLibCheck": true, 17 | "types": ["jasmine", "jest", "node"] 18 | }, 19 | "files": ["src/main.ts", "src/polyfills.ts", "src/test.ts", "src/setup-jest.ts"], 20 | "include": ["src/**/*.spec.ts", "src/**/*.d.ts"] 21 | } 22 | -------------------------------------------------------------------------------- /e2e/jasmine/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /e2e/jasmine/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/jasmine/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /e2e/jasmine/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/jasmine/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Angular Jasmine Only 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/jasmine/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/jasmine/src/tests/issue-000/app.component.ts: -------------------------------------------------------------------------------- 1 | import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; 2 | 3 | import { AppService } from './app.service'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | standalone: false, 8 | template: 'ng-mocks:{{ scope }}', 9 | changeDetection: ChangeDetectionStrategy.OnPush, 10 | }) 11 | export class AppComponent { 12 | @Input() public readonly scope = 'default'; 13 | 14 | public constructor(public readonly service: AppService) {} 15 | } 16 | -------------------------------------------------------------------------------- /e2e/jasmine/src/tests/issue-000/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | import { AppService } from './app.service'; 6 | 7 | @NgModule({ 8 | declarations: [AppComponent], 9 | imports: [BrowserModule], 10 | bootstrap: [AppComponent], 11 | providers: [AppService], 12 | }) 13 | export class AppModule {} 14 | -------------------------------------------------------------------------------- /e2e/jasmine/src/tests/issue-000/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | private readonly name = 'app'; 6 | 7 | public echo1(): string { 8 | return `${this.name}:1`; 9 | } 10 | 11 | public echo2(): string { 12 | return `${this.name}:2`; 13 | } 14 | 15 | public echo3(): string { 16 | return `${this.name}:3`; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /e2e/jest/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /e2e/jest/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/jest/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /e2e/jest/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|mjs|js|html)$': ['jest-preset-angular', { tsconfig: './tsconfig.json' }], 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /e2e/jest/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/jest/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Angular Jest Only 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/jest/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/jest/src/tests/issue-000/app.component.ts: -------------------------------------------------------------------------------- 1 | import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; 2 | 3 | import { AppService } from './app.service'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | standalone: false, 8 | template: 'ng-mocks:{{ scope }}', 9 | changeDetection: ChangeDetectionStrategy.OnPush, 10 | }) 11 | export class AppComponent { 12 | @Input() public readonly scope = 'default'; 13 | 14 | public constructor(public readonly service: AppService) {} 15 | } 16 | -------------------------------------------------------------------------------- /e2e/jest/src/tests/issue-000/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | import { AppService } from './app.service'; 6 | 7 | @NgModule({ 8 | declarations: [AppComponent], 9 | imports: [BrowserModule], 10 | bootstrap: [AppComponent], 11 | providers: [AppService], 12 | }) 13 | export class AppModule {} 14 | -------------------------------------------------------------------------------- /e2e/jest/src/tests/issue-000/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | private readonly name = 'app'; 6 | 7 | public echo1(): string { 8 | return `${this.name}:1`; 9 | } 10 | 11 | public echo2(): string { 12 | return `${this.name}:2`; 13 | } 14 | 15 | public echo3(): string { 16 | return `${this.name}:3`; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /e2e/jest/src/tests/issue-3811/__snapshots__/test.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`issue-3811 should render mock-render without __ngContext__ on the first run 1`] = ` 4 | 5 | 6 |

7 | Hello Joe! 8 |

9 |
10 |
11 | `; 12 | 13 | exports[`issue-3811 should render mock-render without __ngContext__ on the second run 1`] = ` 14 | 15 | 16 |

17 | Hello Jane! 18 |

19 |
20 |
21 | `; 22 | -------------------------------------------------------------------------------- /e2e/jest/src/tests/issue-760/1.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Component, Directive, NgModule } from '@angular/core'; 2 | 3 | import { TargetPipe } from './2.fixtures'; 4 | 5 | @Component({ 6 | selector: 'target', 7 | standalone: false, 8 | template: '{{ name }}', 9 | }) 10 | export class TargetComponent { 11 | public readonly name = 'target'; 12 | } 13 | 14 | @Directive({ 15 | selector: 'target', 16 | standalone: false, 17 | }) 18 | export class TargetDirective { 19 | public readonly name = 'target'; 20 | } 21 | 22 | @NgModule({ 23 | declarations: [TargetComponent, TargetDirective, TargetPipe], 24 | exports: [TargetComponent, TargetDirective, TargetPipe], 25 | }) 26 | export class TargetModule {} 27 | -------------------------------------------------------------------------------- /e2e/jest/src/tests/issue-760/2.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | @Pipe({ 4 | name: 'target', 5 | standalone: false, 6 | }) 7 | export class TargetPipe implements PipeTransform { 8 | public readonly name = 'target'; 9 | 10 | public transform(): string { 11 | return this.name; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /e2e/min/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. 18 | -------------------------------------------------------------------------------- /e2e/min/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/min/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /e2e/min/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | preset: 'jest-preset-angular', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | setupFilesAfterEnv: ['/src/setup-jest.ts'], 6 | testEnvironmentOptions: { 7 | url: 'http://localhost', 8 | }, 9 | testMatch: ['/src/**/*.spec.ts'], 10 | transform: { 11 | '^.+\\.(ts|js|html|svg)$': [ 12 | 'jest-preset-angular', 13 | { 14 | tsconfig: '/tsconfig.json', 15 | stringifyContentPathRegex: '\\.(html|svg)$', 16 | }, 17 | { useESM: true }, 18 | ], 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /e2e/min/ng-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/ng-packagr/ng-package.schema.json", 3 | "dest": "./dist/lib", 4 | "lib": { 5 | "entryFile": "src/app/app.module.ts" 6 | }, 7 | "allowedNonPeerDependencies": ["@angular/", "rxjs", "zone.js"] 8 | } 9 | -------------------------------------------------------------------------------- /e2e/min/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Angular Minimal Dependencies 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/min/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component, enableProdMode, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 4 | 5 | @Component({ 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [AppComponent], 15 | imports: [BrowserModule], 16 | bootstrap: [AppComponent], 17 | }) 18 | class AppModule {} 19 | 20 | enableProdMode(); 21 | 22 | platformBrowserDynamic() 23 | .bootstrapModule(AppModule) 24 | .catch(error => console.error(error)); 25 | -------------------------------------------------------------------------------- /e2e/min/src/setup-jest.ts: -------------------------------------------------------------------------------- 1 | import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone'; // eslint-disable-line import/order 2 | 3 | setupZoneTestEnv(); 4 | -------------------------------------------------------------------------------- /e2e/min/src/test.ts: -------------------------------------------------------------------------------- 1 | // tslint:disable no-import-side-effect ordered-imports 2 | 3 | import { getTestBed } from '@angular/core/testing'; 4 | import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; 5 | 6 | // First, initialize the Angular testing environment. 7 | getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); 8 | -------------------------------------------------------------------------------- /e2e/min/src/tests/issue-000/app.component.html: -------------------------------------------------------------------------------- 1 | {{ title }} 2 | -------------------------------------------------------------------------------- /e2e/min/src/tests/issue-000/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | standalone: false, 6 | templateUrl: './app.component.html', 7 | }) 8 | export class AppComponent { 9 | public readonly title = 'Hello World'; 10 | } 11 | -------------------------------------------------------------------------------- /e2e/min/src/tests/issue-000/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppComponent } from './app.component'; 5 | 6 | @NgModule({ 7 | declarations: [AppComponent], 8 | imports: [BrowserModule], 9 | providers: [], 10 | bootstrap: [AppComponent], 11 | }) 12 | export class AppModule {} 13 | -------------------------------------------------------------------------------- /e2e/nx/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /e2e/nx/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/app 4 | /src/test 5 | -------------------------------------------------------------------------------- /e2e/nx/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /e2e/nx/jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | displayName: 'nx', 3 | workerIdleMemoryLimit: '1024MB', 4 | maxWorkers: 1, 5 | preset: './jest.preset.js', 6 | setupFilesAfterEnv: ['/src/test-setup.ts'], 7 | transform: { 8 | '^.+\\.(ts|mjs|js|html)$': [ 9 | 'jest-preset-angular', 10 | { 11 | tsconfig: '/tsconfig.spec.json', 12 | stringifyContentPathRegex: '\\.(html|svg)$', 13 | }, 14 | ], 15 | }, 16 | transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'], 17 | snapshotSerializers: [ 18 | 'jest-preset-angular/build/serializers/no-ng-attributes', 19 | 'jest-preset-angular/build/serializers/ng-snapshot', 20 | 'jest-preset-angular/build/serializers/html-comment', 21 | ], 22 | testMatch: ['/src/**/*.spec.ts'], 23 | }; 24 | -------------------------------------------------------------------------------- /e2e/nx/jest.preset.js: -------------------------------------------------------------------------------- 1 | const nxPreset = require('@nx/jest/preset').default; 2 | 3 | module.exports = { ...nxPreset }; 4 | -------------------------------------------------------------------------------- /e2e/nx/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NX 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /e2e/nx/src/main.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { bootstrapApplication } from '@angular/platform-browser'; 3 | 4 | @Component({ 5 | standalone: true, 6 | selector: 'app-root', 7 | template: '{{ title }}', 8 | }) 9 | class AppComponent { 10 | public readonly title: string = 'Hello World'; 11 | } 12 | 13 | bootstrapApplication(AppComponent).catch(error => console.error(error)); 14 | -------------------------------------------------------------------------------- /e2e/nx/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./dist/out-tsc", 5 | "module": "commonjs", 6 | "target": "es2016" 7 | }, 8 | "files": ["src/test-setup.ts"], 9 | "include": ["jest.config.ts", "src/**/*.spec.ts"] 10 | } 11 | -------------------------------------------------------------------------------- /empty.ts: -------------------------------------------------------------------------------- 1 | export default undefined; 2 | -------------------------------------------------------------------------------- /examples/MockBuilder/spec.directives.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Directive } from '@angular/core'; 2 | 3 | @Directive({ 4 | selector: 'd-my', 5 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 6 | }) 7 | export class MyDirective {} 8 | 9 | @Directive({ 10 | selector: 'd-keep', 11 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 12 | }) 13 | export class KeepDirective {} 14 | 15 | @Directive({ 16 | selector: '[d-mock]', 17 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 18 | }) 19 | export class MockDirective {} 20 | -------------------------------------------------------------------------------- /examples/MockBuilder/spec.tokens.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { InjectionToken } from '@angular/core'; 2 | 3 | export const TOKEN_KEEP = new InjectionToken('TOKEN_KEEP'); 4 | 5 | export const TOKEN_MOCK = new InjectionToken('TOKEN_MOCK'); 6 | 7 | export const TOKEN_CUSTOMIZE = new InjectionToken('TOKEN_CUSTOMIZE'); 8 | -------------------------------------------------------------------------------- /examples/TestLazyModule/lazy-module.ts: -------------------------------------------------------------------------------- 1 | import { Component, NgModule } from '@angular/core'; 2 | import { RouterModule } from '@angular/router'; 3 | 4 | @Component({ 5 | selector: 'lazy', 6 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 7 | template: 'lazy-component', 8 | }) 9 | export class LazyComponent {} 10 | 11 | @NgModule({ 12 | exports: [RouterModule], 13 | imports: [ 14 | RouterModule.forChild([ 15 | { 16 | component: LazyComponent, 17 | path: '', 18 | }, 19 | ]), 20 | ], 21 | }) 22 | class LazyModuleRouting {} 23 | 24 | @NgModule({ 25 | declarations: [LazyComponent], 26 | imports: [LazyModuleRouting], 27 | }) 28 | export class LazyModule {} 29 | -------------------------------------------------------------------------------- /examples/TestProvider/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | import { MockBuilder, MockRender } from 'ng-mocks'; 4 | 5 | // A simple service, might have contained more logic, 6 | // but it is redundant for the test demonstration. 7 | @Injectable() 8 | class TargetService { 9 | public readonly value = true; 10 | 11 | public echo(): boolean { 12 | return this.value; 13 | } 14 | } 15 | 16 | describe('TestProviderCommon', () => { 17 | // Do not forget to return the promise of MockBuilder. 18 | beforeEach(() => MockBuilder(TargetService)); 19 | 20 | it('returns value on echo', () => { 21 | const service = MockRender(TargetService).point.componentInstance; 22 | 23 | expect(service.echo()).toEqual(service.value); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /karma.ie.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # initialization 4 | export IE_BIN="/c/Program Files/Internet Explorer/iexplore.exe" 5 | cd /c/ && rm -Rf ng-mocks && mkdir ng-mocks && cd ng-mocks 6 | 7 | find /z/ng-mocks/e2e/a5es5 -maxdepth 1 -not -name a5es5 -not -name node_modules -exec cp -r {} . \; 8 | 9 | # installing dependencies 10 | npm install --no-optional --ignore-scripts 11 | 12 | # spreading tests 13 | rm -Rf ./src/test && mkdir src/test && cp -r /z/ng-mocks/tests ./src/test && cp -r /z/ng-mocks/examples ./src/test 14 | rm ./src/test/examples/TestRoutingGuard/test.spec.ts 15 | rm ./src/test/examples/TestRoutingResolver/test.spec.ts 16 | 17 | # spreading ng-mocks 18 | rm -Rf ./node_modules/ng-mocks && cp -r /z/ng-mocks/dist/libs/ng-mocks ./node_modules 19 | 20 | # running tests 21 | npm run test:jasmine 22 | -------------------------------------------------------------------------------- /libs/ng-mocks/migrations.json: -------------------------------------------------------------------------------- 1 | { 2 | "schematics": {} 3 | } 4 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.def-stack.spec.ts: -------------------------------------------------------------------------------- 1 | import CoreDefStack from './core.def-stack'; 2 | 3 | describe('CoreDefStack', () => { 4 | it('returns empty map on empty pop', () => { 5 | const stack = new CoreDefStack(); 6 | 7 | const result1 = stack.pop(); 8 | const result2 = stack.pop(); 9 | 10 | expect(result1).toBeDefined(); 11 | expect(result2).toBeDefined(); 12 | expect(result1).not.toBe(result2); 13 | }); 14 | 15 | it('returns undefined on empty get', () => { 16 | const stack = new CoreDefStack(); 17 | expect(stack.get(CoreDefStack)).toBeUndefined(); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.define-property.ts: -------------------------------------------------------------------------------- 1 | import helperMockService from '../mock-service/helper.mock-service'; 2 | 3 | export default (instance: any, property: keyof any, value: any, enumerable = false) => { 4 | helperMockService.definePropertyDescriptor(instance, property, { 5 | configurable: true, 6 | enumerable, 7 | value, 8 | writable: true, 9 | }); 10 | }; 11 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.form.ts: -------------------------------------------------------------------------------- 1 | import * as module from '@angular/forms'; 2 | 3 | const AbstractControl = module.AbstractControl; 4 | const DefaultValueAccessor = module.DefaultValueAccessor; 5 | const FormControl = module.FormControl; 6 | const FormControlDirective = module.FormControlDirective; 7 | const NG_ASYNC_VALIDATORS = module.NG_ASYNC_VALIDATORS; 8 | const NG_VALIDATORS = module.NG_VALIDATORS; 9 | const NG_VALUE_ACCESSOR = module.NG_VALUE_ACCESSOR; 10 | const NgControl = module.NgControl; 11 | const NgModel = module.NgModel; 12 | 13 | export default { 14 | AbstractControl, 15 | DefaultValueAccessor, 16 | FormControl, 17 | FormControlDirective, 18 | NG_ASYNC_VALIDATORS, 19 | NG_VALIDATORS, 20 | NG_VALUE_ACCESSOR, 21 | NgControl, 22 | NgModel, 23 | }; 24 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.helpers.spec.ts: -------------------------------------------------------------------------------- 1 | import { extendClass } from './core.helpers'; 2 | import decorateMock from './decorate.mock'; 3 | 4 | describe('DebuggableMock', () => { 5 | it('prefixes the class name with MockOf', () => { 6 | class Foo {} 7 | const mock = extendClass(Foo); 8 | decorateMock(mock, Foo); 9 | 10 | expect(mock.name).toBe('MockOfFoo'); 11 | }); 12 | 13 | it('adds a mockOf property that is the class being replaced with a mock copy', () => { 14 | class Bar {} 15 | const mock = extendClass(Bar); 16 | decorateMock(mock, Bar); 17 | 18 | expect((mock as any).mockOf).toBe(Bar); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.injector.ts: -------------------------------------------------------------------------------- 1 | import { Injector } from '@angular/core'; 2 | 3 | import { getTestBedInjection } from './core.helpers'; 4 | 5 | const defaultInjector: any = {}; 6 | 7 | export default (declaration: any, injector: Injector = defaultInjector): any => { 8 | if (injector === defaultInjector) { 9 | return getTestBedInjection(declaration); 10 | } 11 | try { 12 | return injector.get(declaration); 13 | } catch { 14 | return undefined; 15 | } 16 | }; 17 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.reflect.body-catch.ts: -------------------------------------------------------------------------------- 1 | import errorEmptyDef from './error.empty-def'; 2 | import errorJestMock from './error.jest-mock'; 3 | import errorMissingDecorators from './error.missing-decorators'; 4 | 5 | export default (callback: any) => (def: any) => { 6 | errorEmptyDef(def); 7 | 8 | try { 9 | return callback(def); 10 | } catch { 11 | errorJestMock(def); 12 | errorMissingDecorators(def); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.reflect.meta.ts: -------------------------------------------------------------------------------- 1 | import coreReflectDirectiveResolve from './core.reflect.directive-resolve'; 2 | import coreReflectModuleResolve from './core.reflect.module-resolve'; 3 | import { isNgDef } from './func.is-ng-def'; 4 | 5 | export default (value: any): any => { 6 | if (isNgDef(value, 'c')) { 7 | return coreReflectDirectiveResolve(value); 8 | } 9 | if (isNgDef(value, 'd')) { 10 | return coreReflectDirectiveResolve(value); 11 | } 12 | if (isNgDef(value, 'm')) { 13 | return coreReflectModuleResolve(value); 14 | } 15 | 16 | return undefined; 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.reflect.module-resolve.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | 3 | import collectDeclarations from '../resolve/collect-declarations'; 4 | 5 | import coreReflectBodyCatch from './core.reflect.body-catch'; 6 | 7 | export default (def: any): NgModule => 8 | coreReflectBodyCatch((arg: any) => { 9 | const declaration = collectDeclarations(arg); 10 | if (declaration.NgModule) { 11 | return declaration.NgModule; 12 | } 13 | 14 | throw new Error('Cannot resolve declarations'); 15 | })(def); 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.reflect.parameters-resolve.ts: -------------------------------------------------------------------------------- 1 | import collectDeclarations from '../resolve/collect-declarations'; 2 | 3 | export default (def: any): any[] => { 4 | const declaration = collectDeclarations(def); 5 | 6 | return declaration.parameters ?? []; 7 | }; 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.reflect.pipe-resolve.ts: -------------------------------------------------------------------------------- 1 | import { Pipe } from '@angular/core'; 2 | 3 | import collectDeclarations from '../resolve/collect-declarations'; 4 | 5 | import coreReflectBodyCatch from './core.reflect.body-catch'; 6 | 7 | export default (def: any): Pipe & { standalone?: boolean } => 8 | coreReflectBodyCatch((arg: any) => { 9 | const declaration = collectDeclarations(arg); 10 | if (declaration.Pipe) { 11 | return declaration.Pipe; 12 | } 13 | 14 | throw new Error('Cannot resolve declarations'); 15 | })(def); 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.reflect.provided-in.spec.ts: -------------------------------------------------------------------------------- 1 | import coreReflectProvidedIn from './core.reflect.provided-in'; 2 | 3 | describe('core.reflect.provided-in', () => { 4 | it('covers ngInjectableDef', () => { 5 | expect( 6 | coreReflectProvidedIn({ 7 | ngInjectableDef: {}, 8 | }), 9 | ).toEqual(undefined); 10 | expect( 11 | coreReflectProvidedIn({ 12 | ngInjectableDef: { 13 | providedIn: 'root', 14 | }, 15 | }), 16 | ).toEqual('root'); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/core.reflect.provided-in.ts: -------------------------------------------------------------------------------- 1 | import { AnyType } from './core.types'; 2 | 3 | export default (declaration: any): undefined | AnyType | string => { 4 | if (!declaration || (typeof declaration !== 'object' && typeof declaration !== 'function')) { 5 | return undefined; 6 | } 7 | 8 | return declaration.ɵprov?.providedIn ?? declaration.ngInjectableDef?.providedIn; 9 | }; 10 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/error.empty-def.spec.ts: -------------------------------------------------------------------------------- 1 | import errorEmptyDef from './error.empty-def'; 2 | 3 | describe('error.empty-def', () => { 4 | it('skips defined values', () => { 5 | expect(() => errorEmptyDef(true)).not.toThrow(); 6 | expect(() => errorEmptyDef(class Test {})).not.toThrow(); 7 | expect(() => errorEmptyDef(() => undefined)).not.toThrow(); 8 | }); 9 | 10 | it('throws on undefined values', () => { 11 | expect(() => errorEmptyDef(undefined)).toThrowError( 12 | /undefined \/ null has been passed into ng-mocks/, 13 | ); 14 | expect(() => errorEmptyDef(null)).toThrowError( 15 | /undefined \/ null has been passed into ng-mocks/, 16 | ); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/error.empty-def.ts: -------------------------------------------------------------------------------- 1 | export default (def: any): void => { 2 | if (!def) { 3 | throw new Error( 4 | [ 5 | 'undefined / null has been passed into ng-mocks as a declaration / provider.', 6 | 'Please ensure that the current test file has correct imports:', 7 | 'imported files exist and imported declarations have been exported in the file.', 8 | ].join(' '), 9 | ); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/error.jest-mock.ts: -------------------------------------------------------------------------------- 1 | import funcGetName from './func.get-name'; 2 | import funcIsJestMock from './func.is-jest-mock'; 3 | 4 | export default (def: any): void => { 5 | if (funcIsJestMock(def)) { 6 | throw new Error( 7 | [ 8 | `ng-mocks got ${funcGetName(def)} which has been already mocked by jest.mock().`, 9 | 'It is not possible to produce correct mocks for it, because jest.mock() removes Angular decorators.', 10 | `To fix this, please avoid jest.mock() on the file which exports ${funcGetName( 11 | def, 12 | )} or add jest.dontMock() on it.`, 13 | 'The same should be done for all related dependencies.', 14 | ].join(' '), 15 | ); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/error.missing-decorators.ts: -------------------------------------------------------------------------------- 1 | import funcGetName from './func.get-name'; 2 | 3 | export default (def: any): void => { 4 | throw new Error( 5 | [ 6 | `${funcGetName(def)} declaration has been passed into ng-mocks without Angular decorators.`, 7 | 'Therefore, it cannot be properly handled.', 8 | 'Highly likely,', 9 | typeof jest === 'undefined' ? '' : /* istanbul ignore next */ 'jest.mock() has been used on its file, or', 10 | 'ng-mocks is imported in production code, or got a class without Angular decoration.', 11 | 'Otherwise, please create an issue on github: https://github.com/help-me-mom/ng-mocks/issues/new?title=False%20positive%20ng-mocks%20not%20in%20JIT.', 12 | 'Thank you in advance for support.', 13 | ].join(' '), 14 | ); 15 | }; 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.directive-io-build.ts: -------------------------------------------------------------------------------- 1 | import { DirectiveIo, DirectiveIoParsed } from './core.types'; 2 | 3 | export default function ({ name, alias, required }: DirectiveIoParsed, skipName = false): DirectiveIo { 4 | if (required) { 5 | return { name, alias, required }; 6 | } 7 | if (!alias || name === alias) { 8 | return skipName ? '' : name; 9 | } 10 | 11 | return skipName ? alias : `${name}:${alias}`; 12 | } 13 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.directive-io-parse.ts: -------------------------------------------------------------------------------- 1 | import { DirectiveIo, DirectiveIoParsed } from './core.types'; 2 | 3 | export default function (param: DirectiveIo): DirectiveIoParsed { 4 | if (typeof param === 'string') { 5 | const [name, alias] = param.split(':').map(v => v.trim()); 6 | 7 | if (name === alias || !alias) { 8 | return { name }; 9 | } 10 | 11 | return { name, alias }; 12 | } 13 | 14 | return param; 15 | } 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.extract-forward-ref.ts: -------------------------------------------------------------------------------- 1 | // handles forwardRef on useExisting 2 | export default (provide: any): any => { 3 | if (typeof provide === 'function' && provide.__forward_ref__) { 4 | return provide(); 5 | } 6 | 7 | return provide; 8 | }; 9 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.get-global.ts: -------------------------------------------------------------------------------- 1 | export default (): Record => { 2 | // istanbul ignore if 3 | if (typeof window === 'undefined') { 4 | return global; 5 | } 6 | 7 | return window; 8 | }; 9 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.get-name.spec.ts: -------------------------------------------------------------------------------- 1 | import funcGetName from './func.get-name'; 2 | 3 | describe('func.get-name', () => { 4 | it('detects unknown', () => { 5 | expect(funcGetName(false)).toEqual('unknown'); 6 | }); 7 | }); 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.get-name.ts: -------------------------------------------------------------------------------- 1 | const badCharacters = new RegExp('[^0-9a-z]+', 'mgi'); 2 | 3 | export default (value: any): string => { 4 | let result: string | undefined; 5 | 6 | if (typeof value === 'function' && value.name) { 7 | result = value.name; 8 | } else if (typeof value === 'function') { 9 | result = 'arrowFunction'; 10 | } else if (typeof value === 'object' && value && value.ngMetadataName === 'InjectionToken') { 11 | result = value._desc; 12 | } else if (typeof value === 'object' && value && typeof value.constructor === 'function') { 13 | result = value.constructor.name; 14 | } 15 | 16 | result ||= 'unknown'; 17 | 18 | return result.replace(badCharacters, '_'); 19 | }; 20 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.get-type.ts: -------------------------------------------------------------------------------- 1 | import { isNgModuleDefWithProviders } from './func.is-ng-module-def-with-providers'; 2 | 3 | export default (provider: any): any => { 4 | return provider && typeof provider === 'object' && provider.provide 5 | ? provider.provide 6 | : isNgModuleDefWithProviders(provider) 7 | ? provider.ngModule 8 | : provider && typeof provider === 'object' && provider.directive 9 | ? provider.directive 10 | : provider; 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.is-jest-mock.ts: -------------------------------------------------------------------------------- 1 | export default (def: any): boolean => { 2 | if (!def) { 3 | return false; 4 | } 5 | 6 | if (typeof def !== 'function' && typeof def !== 'object') { 7 | return false; 8 | } 9 | 10 | if (def._isMockFunction && def.mockName && def.__annotations__) { 11 | return true; 12 | } 13 | 14 | return false; 15 | }; 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.is-mock-control-value-accessor.ts: -------------------------------------------------------------------------------- 1 | import funcIsMock from './func.is-mock'; 2 | import { MockControlValueAccessor } from './mock-control-value-accessor'; 3 | 4 | /** 5 | * isMockControlValueAccessor helps to assert that an instance is a mock ControlValueAccessor 6 | * to perform valueChange or touch simulations. 7 | * Usually, it is used in if statements. 8 | * 9 | * @see https://ng-mocks.sudo.eu/api/helpers/isMockControlValueAccessor 10 | * @see https://ng-mocks.sudo.eu/api/ngMocks/change 11 | * @see https://ng-mocks.sudo.eu/api/ngMocks/touch 12 | */ 13 | export const isMockControlValueAccessor = (value: T): value is T & MockControlValueAccessor => { 14 | if (!funcIsMock(value)) { 15 | return false; 16 | } 17 | 18 | return !!value.__ngMocksConfig.isControlValueAccessor; 19 | }; 20 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.is-mock-validator.ts: -------------------------------------------------------------------------------- 1 | import funcIsMock from './func.is-mock'; 2 | import { MockValidator } from './mock-control-value-accessor'; 3 | 4 | /** 5 | * isMockValidator helps to assert that an instance is a mock Validator 6 | * to perform validationChange simulations. 7 | * Usually, it is used in if statements. 8 | * 9 | * @see https://ng-mocks.sudo.eu/api/helpers/isMockValidator 10 | */ 11 | export const isMockValidator = (value: T): value is T & MockValidator => { 12 | if (!funcIsMock(value)) { 13 | return false; 14 | } 15 | 16 | return !!(value as any).__ngMocksConfig.isValidator; 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.is-mock.ts: -------------------------------------------------------------------------------- 1 | import { Injector, TemplateRef, ViewContainerRef } from '@angular/core'; 2 | 3 | import { MockConfig } from './mock'; 4 | 5 | export default ( 6 | value: T, 7 | ): value is T & 8 | MockConfig & { 9 | __ngMocksInjector?: Injector; 10 | __template?: TemplateRef; 11 | __vcr?: ViewContainerRef; 12 | } => { 13 | return value && typeof value === 'object' && !!(value as any).__ngMocks; 14 | }; 15 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.is-ng-injection-token.ts: -------------------------------------------------------------------------------- 1 | import { InjectionToken } from '@angular/core'; 2 | 3 | /** 4 | * Checks whether a variable is an Angular token. 5 | * 6 | * @see https://ng-mocks.sudo.eu/api/helpers/isNgInjectionToken 7 | * 8 | * ```ts 9 | * isNgInjectionToken(APP_ID); // returns true 10 | * isNgInjectionToken(arbitraryVariable); // returns false 11 | * ``` 12 | */ 13 | export const isNgInjectionToken = (token: any): token is InjectionToken => 14 | token && typeof token === 'object' && token.ngMetadataName === 'InjectionToken'; 15 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.is-ng-module-def-with-providers.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | 3 | import { Type } from './core.types'; 4 | 5 | /** 6 | * NgModuleWithProviders helps to support ModuleWithProviders in all angular versions. 7 | * In A5 it was without the generic type. 8 | * 9 | * @internal remove after removal of A5 support 10 | */ 11 | export interface NgModuleWithProviders { 12 | ngModule: Type; 13 | providers?: NgModule['providers']; 14 | } 15 | 16 | /** 17 | * isNgModuleDefWithProviders checks if an object implements ModuleWithProviders. 18 | * 19 | * @internal 20 | */ 21 | export const isNgModuleDefWithProviders = (declaration: any): declaration is NgModuleWithProviders => 22 | declaration && typeof declaration === 'object' && typeof declaration.ngModule === 'function'; 23 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/common/func.is-standalone.ts: -------------------------------------------------------------------------------- 1 | import collectDeclarations from '../resolve/collect-declarations'; 2 | 3 | import { getNgType } from './func.get-ng-type'; 4 | 5 | /** 6 | * Checks whether a class has been decorated with the standalone flag. 7 | */ 8 | export function isStandalone(declaration: any): boolean { 9 | const type = getNgType(declaration); 10 | if (!type || type === 'Injectable' || type === 'NgModule') { 11 | return false; 12 | } 13 | 14 | return collectDeclarations(declaration)[type].standalone === true; 15 | } 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/performance/are-equal-config-params.ts: -------------------------------------------------------------------------------- 1 | import equalRenderConfigs from './equal-render-configs'; 2 | 3 | export default (source: any, destination: any): boolean => { 4 | if (destination === source) { 5 | return true; 6 | } 7 | if (destination.dependency !== source.dependency) { 8 | return false; 9 | } 10 | if (destination.export !== source.export) { 11 | return false; 12 | } 13 | if (destination.exportAll !== source.exportAll) { 14 | return false; 15 | } 16 | if (!equalRenderConfigs(source.render, destination.render)) { 17 | return false; 18 | } 19 | 20 | return true; 21 | }; 22 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/performance/are-equal-maps.ts: -------------------------------------------------------------------------------- 1 | import { mapKeys } from '../../common/core.helpers'; 2 | 3 | export default (source: Map, destination: Map, compare = (a: any, b: any) => a === b): boolean => { 4 | if (!destination || destination.size !== source.size) { 5 | return false; 6 | } 7 | for (const value of mapKeys(source)) { 8 | if (!destination.has(value)) { 9 | return false; 10 | } 11 | if (!compare(destination.get(value), source.get(value))) { 12 | return false; 13 | } 14 | } 15 | 16 | return true; 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/performance/are-equal-sets.ts: -------------------------------------------------------------------------------- 1 | import { mapValues } from '../../common/core.helpers'; 2 | 3 | export default (source: Set, destination: Set): boolean => { 4 | if (!destination || destination.size !== source.size) { 5 | return false; 6 | } 7 | for (const value of mapValues(source)) { 8 | if (!destination.has(value)) { 9 | return false; 10 | } 11 | } 12 | 13 | return true; 14 | }; 15 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/performance/equal-render-defs.ts: -------------------------------------------------------------------------------- 1 | import equalVariables from './equal-variables'; 2 | 3 | export default (prototype: any, source: any): boolean => { 4 | if (prototype === source) { 5 | return true; 6 | } 7 | if ((typeof prototype === 'boolean' || typeof source === 'boolean') && prototype !== source) { 8 | return false; 9 | } 10 | 11 | return prototype.$implicit === source.$implicit && equalVariables(prototype.variables, source.variables); 12 | }; 13 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/performance/equal-variables.ts: -------------------------------------------------------------------------------- 1 | const objectsDiffer = (prototype: any, source: any): boolean => { 2 | const prototypeKeys = Object.keys(prototype); 3 | const sourceKeys = Object.keys(source); 4 | if (prototypeKeys.length !== sourceKeys.length) { 5 | return true; 6 | } 7 | for (const key of prototypeKeys) { 8 | if (prototype[key] !== source[key]) { 9 | return true; 10 | } 11 | } 12 | 13 | return false; 14 | }; 15 | 16 | export default (prototype: any, source: any): boolean => { 17 | if (prototype === source) { 18 | return true; 19 | } 20 | if ((prototype && !source) || (!prototype && source)) { 21 | return false; 22 | } 23 | if (objectsDiffer(prototype, source)) { 24 | return false; 25 | } 26 | 27 | return true; 28 | }; 29 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/performance/get-empty-config.ts: -------------------------------------------------------------------------------- 1 | export default () => ({ 2 | beforeCC: new Set(), 3 | configDef: new Map(), 4 | defProviders: new Map(), 5 | defValue: new Map(), 6 | excludeDef: new Set(), 7 | keepDef: new Set(), 8 | mockDef: new Set(), 9 | providerDef: new Map(), 10 | replaceDef: new Set(), 11 | }); 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/performance/required-metadata.ts: -------------------------------------------------------------------------------- 1 | import { TestModuleMetadata } from '@angular/core/testing'; 2 | 3 | export default ( 4 | ngModule: TestModuleMetadata, 5 | ): TestModuleMetadata & { 6 | declarations: any[]; 7 | imports: any[]; 8 | providers: any[]; 9 | } => ({ 10 | ...ngModule, 11 | declarations: [...(ngModule.declarations || /* istanbul ignore next */ [])], 12 | imports: [...(ngModule.imports || /* istanbul ignore next */ [])], 13 | providers: [...(ngModule.providers || /* istanbul ignore next */ [])], 14 | }); 15 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/add-def-to-root-provider-parameters.ts: -------------------------------------------------------------------------------- 1 | import { NG_MOCKS_ROOT_PROVIDERS } from '../../common/core.tokens'; 2 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 3 | 4 | import skipDep from './skip-dep'; 5 | import { BuilderData } from './types'; 6 | 7 | export default (parameters: Set, mockDef: BuilderData['mockDef'], def: any): void => { 8 | if ( 9 | !skipDep(def) && 10 | (mockDef.has(NG_MOCKS_ROOT_PROVIDERS) || !ngMocksUniverse.config.get('ngMocksDepsSkip').has(def)) 11 | ) { 12 | parameters.add(def); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/apply-platform-modules.ts: -------------------------------------------------------------------------------- 1 | import { getTestBed } from '@angular/core/testing'; 2 | 3 | import { flatten } from '../../common/core.helpers'; 4 | import funcGetType from '../../common/func.get-type'; 5 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 6 | 7 | export default () => { 8 | const testBed = getTestBed(); 9 | // istanbul ignore else 10 | if (testBed.ngModule) { 11 | for (const def of flatten(testBed.ngModule)) { 12 | ngMocksUniverse.touches.add(funcGetType(def)); 13 | } 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/check-root-provider-dependency.ts: -------------------------------------------------------------------------------- 1 | export default (provide: any, bucket: any[], touched: any[]): void => { 2 | if (typeof provide === 'function' && touched.indexOf(provide) === -1) { 3 | touched.push(provide); 4 | bucket.push(provide); 5 | } 6 | }; 7 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/extract-dep.ts: -------------------------------------------------------------------------------- 1 | import funcExtractForwardRef from '../../common/func.extract-forward-ref'; 2 | 3 | // Extracts dependency among flags of parameters. 4 | export default (decorators?: any[]): any => { 5 | if (!decorators) { 6 | return; 7 | } 8 | 9 | let provide: any; 10 | for (const decorator of decorators) { 11 | if (decorator && typeof decorator === 'object' && decorator.token) { 12 | provide = decorator.token; 13 | } 14 | if (!provide && decorator && (typeof decorator !== 'object' || !decorator.ngMetadataName)) { 15 | provide = decorator; 16 | } 17 | } 18 | 19 | return funcExtractForwardRef(provide); 20 | }; 21 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/get-override-def.ts: -------------------------------------------------------------------------------- 1 | import { Directive, NgModule } from '@angular/core'; 2 | 3 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 4 | import mockNgDef from '../../mock-module/mock-ng-def'; 5 | 6 | export default (meta?: Directive | NgModule): NgModule | undefined => { 7 | if (!meta) { 8 | return undefined; 9 | } 10 | 11 | const skipMock = ngMocksUniverse.flags.has('skipMock'); 12 | // istanbul ignore else 13 | if (!skipMock) { 14 | ngMocksUniverse.flags.add('skipMock'); 15 | } 16 | const [changed, def] = mockNgDef(meta); 17 | // istanbul ignore else 18 | if (!skipMock) { 19 | ngMocksUniverse.flags.delete('skipMock'); 20 | } 21 | if (!changed) { 22 | return undefined; 23 | } 24 | 25 | return def; 26 | }; 27 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/get-root-providers-data.ts: -------------------------------------------------------------------------------- 1 | import { mapValues } from '../../common/core.helpers'; 2 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 3 | 4 | export default (): { 5 | buckets: any[]; 6 | touched: any[]; 7 | } => { 8 | // We need buckets here to process first all depsSkip, then deps and only after that all other defs. 9 | const buckets: any[] = [ 10 | mapValues(ngMocksUniverse.config.get('ngMocksDepsSkip')), 11 | mapValues(ngMocksUniverse.config.get('ngMocksDeps')), 12 | mapValues(ngMocksUniverse.touches), 13 | ]; 14 | 15 | // Also, we need to track what has been touched to check params recursively, but avoiding duplicates. 16 | const touched: any[] = [].concat(...buckets); 17 | 18 | return { 19 | buckets, 20 | touched, 21 | }; 22 | }; 23 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/handle-provided-in-dependency.ts: -------------------------------------------------------------------------------- 1 | import coreReflectProvidedIn from '../../common/core.reflect.provided-in'; 2 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 3 | 4 | export default (provide: any): void => { 5 | if (ngMocksUniverse.touches.has(provide)) { 6 | return; 7 | } 8 | 9 | const providedIn = coreReflectProvidedIn(provide); 10 | if (!providedIn) { 11 | return; 12 | } 13 | 14 | if (ngMocksUniverse.config.get('ngMocksDepsSkip').has(providedIn)) { 15 | ngMocksUniverse.config.get('ngMocksDepsSkip').add(provide); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/init-exclude-def.ts: -------------------------------------------------------------------------------- 1 | import { mapValues } from '../../common/core.helpers'; 2 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 3 | 4 | export default (excludeDef: Set): void => { 5 | const builtDeclarations = ngMocksUniverse.builtDeclarations; 6 | const builtProviders = ngMocksUniverse.builtProviders; 7 | const resolutions = ngMocksUniverse.config.get('ngMocksDepsResolution'); 8 | for (const def of mapValues(excludeDef)) { 9 | builtDeclarations.set(def, null); 10 | builtProviders.set(def, null); 11 | resolutions.set(def, 'exclude'); 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/init-mock-declarations.ts: -------------------------------------------------------------------------------- 1 | import { mapValues } from '../../common/core.helpers'; 2 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 3 | 4 | import tryMockProvider from './try-mock-provider'; 5 | 6 | export default (mockDef: Set, defValue: Map): void => { 7 | const builtDeclarations = ngMocksUniverse.builtDeclarations; 8 | const resolutions: Map = ngMocksUniverse.config.get('ngMocksDepsResolution'); 9 | for (const def of mapValues(mockDef)) { 10 | const deleteTouch = !ngMocksUniverse.touches.has(def); 11 | 12 | resolutions.set(def, 'mock'); 13 | builtDeclarations.set(def, undefined); 14 | tryMockProvider(def, defValue); 15 | 16 | if (deleteTouch) { 17 | ngMocksUniverse.touches.delete(def); 18 | } 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/init-module.ts: -------------------------------------------------------------------------------- 1 | import { ModuleWithProviders } from '@angular/core'; 2 | 3 | import { Type } from '../../common/core.types'; 4 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 5 | 6 | import { BuilderData } from './types'; 7 | 8 | export default (def: Type, defProviders: BuilderData['defProviders']): Type | ModuleWithProviders => { 9 | const loModule = ngMocksUniverse.config.get('mockNgDefResolver').get(def) ?? ngMocksUniverse.getBuildDeclaration(def); 10 | const loProviders = defProviders.has(def) ? defProviders.get(def) : undefined; 11 | 12 | return loProviders 13 | ? { 14 | ngModule: loModule, 15 | providers: loProviders, 16 | } 17 | : loModule; 18 | }; 19 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/init-replace-def.ts: -------------------------------------------------------------------------------- 1 | import { mapValues } from '../../common/core.helpers'; 2 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 3 | 4 | export default (replaceDef: Set, defValue: Map): void => { 5 | const builtDeclarations = ngMocksUniverse.builtDeclarations; 6 | const resolutions = ngMocksUniverse.config.get('ngMocksDepsResolution'); 7 | for (const def of mapValues(replaceDef)) { 8 | builtDeclarations.set(def, defValue.get(def)); 9 | resolutions.set(def, 'replace'); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/parse-mock-arguments.ts: -------------------------------------------------------------------------------- 1 | import { isNgDef } from '../../common/func.is-ng-def'; 2 | 3 | export default ( 4 | def: any, 5 | a1: any, 6 | a2: any, 7 | defaultMockValue: any, 8 | ): { 9 | config: any; 10 | mock: any; 11 | } => { 12 | let mock: any = def === a1 ? defaultMockValue : a1; 13 | let config: any = a2 ?? (a1 !== defaultMockValue && typeof a1 === 'object' ? a1 : undefined); 14 | if (isNgDef(def, 'p') && typeof a1 === 'function' && a1 !== def && !isNgDef(a1, 'p')) { 15 | mock = { 16 | transform: a1, 17 | }; 18 | config = a2; 19 | } else if (isNgDef(def, 'i') || !isNgDef(def)) { 20 | config = a2; 21 | } 22 | mock = mock === config ? defaultMockValue : mock; 23 | 24 | return { 25 | config, 26 | mock, 27 | }; 28 | }; 29 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/parse-provider.ts: -------------------------------------------------------------------------------- 1 | import funcGetType from '../../common/func.get-type'; 2 | 3 | export default ( 4 | provider: any, 5 | ): { 6 | multi: boolean; 7 | provide: any; 8 | } => { 9 | const provide = funcGetType(provider); 10 | const multi = provide !== provider && provider.multi; 11 | 12 | return { 13 | multi, 14 | provide, 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/skip-override.ts: -------------------------------------------------------------------------------- 1 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 2 | 3 | import { BuilderData } from './types'; 4 | 5 | export default ( 6 | replaceDef: BuilderData['replaceDef'], 7 | defValue: BuilderData['defValue'], 8 | source: any, 9 | value: any, 10 | ): boolean => { 11 | // no reason to touch mocks 12 | if (ngMocksUniverse.cacheDeclarations.has(value)) { 13 | return true; 14 | } 15 | 16 | // no customizations in replacements 17 | if (replaceDef.has(source) && value === defValue.get(source)) { 18 | return true; 19 | } 20 | 21 | return false; 22 | }; 23 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-builder/promise/skip-root-provider-dependency.ts: -------------------------------------------------------------------------------- 1 | import ngMocksUniverse from '../../common/ng-mocks-universe'; 2 | 3 | import skipDep from './skip-dep'; 4 | 5 | export default (provide: any): boolean => { 6 | if (skipDep(provide)) { 7 | return true; 8 | } 9 | 10 | return ngMocksUniverse.config.get('ngMocksDepsSkip').has(provide); 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-component/mock-component.spec.child-component.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'child-component', 5 | standalone: false, 6 | template: 'some template', 7 | }) 8 | export class ChildComponent { 9 | public performAction(s: string) { 10 | return s ? this : this; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-component/mock-component.spec.empty-component.component.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Component, forwardRef } from '@angular/core'; 2 | import { NG_VALUE_ACCESSOR } from '@angular/forms'; 3 | 4 | @Component({ 5 | providers: [ 6 | { 7 | multi: true, 8 | provide: NG_VALUE_ACCESSOR, 9 | useExisting: forwardRef(() => EmptyComponent), 10 | }, 11 | ], 12 | selector: 'empty-component', 13 | standalone: false, 14 | template: 'some template', 15 | }) 16 | export class EmptyComponent {} 17 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-component/mock-component.spec.getter-setter.component.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Component, Input } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'getter-setter', 5 | standalone: false, 6 | template: '', 7 | }) 8 | export class GetterSetterComponent { 9 | @Input() 10 | public normalInput?: boolean; 11 | 12 | public normalProperty = false; 13 | 14 | protected value: any; 15 | 16 | public get myGetter() { 17 | return true; 18 | } 19 | 20 | public set mySetter(value: string) { 21 | this.value = value; 22 | } 23 | 24 | public normalMethod(): boolean { 25 | return this.myGetter; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-component/render/get-key.ts: -------------------------------------------------------------------------------- 1 | export default ( 2 | contentChildSelector: string | [string, ...number[]], 3 | ): [string, string, string, undefined | number[]] => { 4 | if (typeof contentChildSelector === 'string') { 5 | return ['key', `__mockTpl_key_${contentChildSelector}`, contentChildSelector, undefined]; 6 | } 7 | 8 | const [key, ...indices] = contentChildSelector; 9 | 10 | return ['prop', key, key, indices.length > 0 ? indices : undefined]; 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/crawl-by-attribute.ts: -------------------------------------------------------------------------------- 1 | import { MockedDebugNode } from '../../mock-render/types'; 2 | 3 | import detectAttributeInSelectors from './detect-attribute-in-selectors'; 4 | import detectSelectorsFromNode from './detect-selectors-from-node'; 5 | 6 | export default (attribute: string): ((node: MockedDebugNode) => boolean) => 7 | node => { 8 | const [selectors, attributes] = detectSelectorsFromNode(node); 9 | 10 | if (attributes.indexOf(attribute) !== -1) { 11 | return true; 12 | } 13 | 14 | if (detectAttributeInSelectors(selectors, attribute)) { 15 | return true; 16 | } 17 | 18 | return false; 19 | }; 20 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/crawl-by-declaration.ts: -------------------------------------------------------------------------------- 1 | import coreInjector from '../../common/core.injector'; 2 | import { AnyType } from '../../common/core.types'; 3 | import { getSourceOfMock } from '../../common/func.get-source-of-mock'; 4 | import { MockedDebugNode } from '../../mock-render/types'; 5 | 6 | export default (declaration: AnyType): ((node: MockedDebugNode) => boolean) => { 7 | const source = getSourceOfMock(declaration); 8 | 9 | return node => 10 | !!node && node.providerTokens.indexOf(source) !== -1 && coreInjector(source, node.injector) !== undefined; 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/crawl-by-id.ts: -------------------------------------------------------------------------------- 1 | import { MockedDebugNode } from '../../mock-render/types'; 2 | 3 | export default (id: string): ((node: MockedDebugNode) => boolean) => 4 | node => { 5 | return !!node.references[id]; 6 | }; 7 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/crawl-by-tag-name.ts: -------------------------------------------------------------------------------- 1 | import { MockedDebugNode } from '../../mock-render/types'; 2 | 3 | import detectSelectorsFromNode from './detect-selectors-from-node'; 4 | import detectTagNameInSelectors from './detect-tag-name-in-selectors'; 5 | 6 | export default (attribute: string): ((node: MockedDebugNode) => boolean) => 7 | node => { 8 | const [selectors] = detectSelectorsFromNode(node); 9 | 10 | return detectTagNameInSelectors(selectors, attribute); 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/detect-attribute-in-selectors.ts: -------------------------------------------------------------------------------- 1 | export default (selectors: string[], query: string): boolean => { 2 | for (const selector of selectors) { 3 | const attributes = selector.match(/\[([^=\]]+)/g); 4 | if (!attributes) { 5 | continue; 6 | } 7 | 8 | for (const attribute of attributes) { 9 | if (attribute === `[${query}`) { 10 | return true; 11 | } 12 | } 13 | } 14 | 15 | return false; 16 | }; 17 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/detect-tag-name-in-selectors.ts: -------------------------------------------------------------------------------- 1 | const regExp = new RegExp('\\[.*?\\]', 'g'); 2 | 3 | export default (selectors: string[], query: string): boolean => { 4 | for (const selector of selectors) { 5 | const attributes = selector.replace(regExp, '').split(','); 6 | 7 | for (const attribute of attributes) { 8 | if (attribute.trim() === query) { 9 | return true; 10 | } 11 | } 12 | } 13 | 14 | return false; 15 | }; 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/detect-text-node.ts: -------------------------------------------------------------------------------- 1 | import { MockedDebugNode } from '../../mock-render/types'; 2 | 3 | export default (node: MockedDebugNode): boolean => { 4 | return node.nativeNode.nodeName === '#text'; 5 | }; 6 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/el-def-compare.ts: -------------------------------------------------------------------------------- 1 | export default (a: any, b: any): boolean => { 2 | if (!a || !b) { 3 | return false; 4 | } 5 | 6 | return a === b; 7 | }; 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/el-def-get-node.ts: -------------------------------------------------------------------------------- 1 | import detectTextNode from './detect-text-node'; 2 | 3 | export default (node: any) => { 4 | return detectTextNode(node) 5 | ? undefined 6 | : node.injector._tNode || // ivy 7 | node.injector.elDef || // classic 8 | undefined; 9 | }; 10 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/func.get-public-provider-keys.ts: -------------------------------------------------------------------------------- 1 | import { MockedDebugNode } from '../../mock-render/types'; 2 | 3 | export default (node: MockedDebugNode): string[] => { 4 | return (node.injector as any).elDef ? Object.keys((node.injector as any).elDef.element.publicProviders) : []; 5 | }; 6 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/func.is-valid-reveal-selector.ts: -------------------------------------------------------------------------------- 1 | export default (value: any) => { 2 | if (typeof value === 'string') { 3 | return true; 4 | } 5 | if (Array.isArray(value) && typeof value[0] === 'string') { 6 | return true; 7 | } 8 | 9 | return typeof value === 'function'; 10 | }; 11 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/crawl/mock-helper.crawl.ts: -------------------------------------------------------------------------------- 1 | import { DebugNode } from '@angular/core'; 2 | 3 | import { DebugNodeSelector } from '../../common/core.types'; 4 | import mockHelperFind from '../find/mock-helper.find'; 5 | import funcGetLastFixture from '../func.get-last-fixture'; 6 | 7 | import nestedCheck from './nested-check'; 8 | 9 | export default ( 10 | sel: DebugNode | DebugNodeSelector, 11 | callback: (node: DebugNode, parent?: DebugNode) => void | boolean, 12 | includeTextNode = false, 13 | ): void => { 14 | const el = mockHelperFind(funcGetLastFixture(), sel, undefined); 15 | nestedCheck(el, undefined, callback, includeTextNode); 16 | }; 17 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/events/mock-helper.click.ts: -------------------------------------------------------------------------------- 1 | import { DebugNodeSelector } from '../../common/core.types'; 2 | 3 | import mockHelperTrigger from './mock-helper.trigger'; 4 | 5 | export default (selector: DebugNodeSelector, payload?: object) => { 6 | mockHelperTrigger(selector, 'click', payload); 7 | }; 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/find-instance/func.is-valid-find-instance-selector.ts: -------------------------------------------------------------------------------- 1 | import { isNgDef } from '../../common/func.is-ng-def'; 2 | 3 | export default (value: any): boolean => { 4 | return typeof value === 'function' || isNgDef(value, 't'); 5 | }; 6 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/find/func.parse-find-term.ts: -------------------------------------------------------------------------------- 1 | import { DebugElement, Predicate } from '@angular/core'; 2 | import { By } from '@angular/platform-browser'; 3 | 4 | import { AnyType } from '../../common/core.types'; 5 | import { getSourceOfMock } from '../../common/func.get-source-of-mock'; 6 | 7 | export default (selector: string | AnyType | [string] | [string, any]): Predicate => { 8 | return Array.isArray(selector) 9 | ? By.css(selector.length === 1 ? `[${selector[0]}]` : `[${selector[0]}="${selector[1]}"]`) 10 | : typeof selector === 'string' 11 | ? By.css(selector) 12 | : By.directive(getSourceOfMock(selector)); 13 | }; 14 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/find/mock-helper.find-all.ts: -------------------------------------------------------------------------------- 1 | import { DebugElement } from '@angular/core'; 2 | 3 | import isDebugNode from '../format/is-debug-node'; 4 | 5 | import funcParseFindArgs from './func.parse-find-args'; 6 | import funcParseFindTerm from './func.parse-find-term'; 7 | 8 | export default (...args: any[]): DebugElement[] => { 9 | const [el, sel] = funcParseFindArgs(args); 10 | if (isDebugNode(sel)) { 11 | return [sel as any]; 12 | } 13 | 14 | return el?.queryAll(funcParseFindTerm(sel)) || []; 15 | }; 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/format/handle-array.ts: -------------------------------------------------------------------------------- 1 | export default (format: any, html: any) => { 2 | return format((html as any[]).map(item => format(item, true)).join('')); 3 | }; 4 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/format/handle-text.ts: -------------------------------------------------------------------------------- 1 | export default (html: Text): string => html.nodeValue ?? html.textContent ?? html.wholeText; 2 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/format/is-debug-node.ts: -------------------------------------------------------------------------------- 1 | import { MockedDebugNode } from '../../mock-render/types'; 2 | 3 | export default (value: any): value is MockedDebugNode => { 4 | return !!value?.nativeElement || !!value?.nativeNode; 5 | }; 6 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/format/is-fixture.ts: -------------------------------------------------------------------------------- 1 | import { MockedDebugNode } from '../../mock-render/types'; 2 | 3 | export default (value: any): value is { debugElement: MockedDebugNode } => { 4 | return !!value && typeof value === 'object' && value.debugElement !== undefined; 5 | }; 6 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/format/is-html-element.ts: -------------------------------------------------------------------------------- 1 | export default (value: any): value is HTMLElement => { 2 | return !!value && typeof value === 'object' && value.innerHTML !== undefined; 3 | }; 4 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/format/is-text.ts: -------------------------------------------------------------------------------- 1 | export default (value: any): value is Text => { 2 | return !!value && typeof value === 'object' && value.nodeName === '#text'; 3 | }; 4 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/format/types.ts: -------------------------------------------------------------------------------- 1 | export type FORMAT_SINGLE = string | HTMLElement | { nativeNode: any } | { nativeElement: any } | { debugElement: any }; 2 | export type FORMAT_SET = 3 | | string[] 4 | | HTMLElement[] 5 | | Array<{ nativeNode: any }> 6 | | Array<{ nativeElement: any }> 7 | | Array<{ debugElement: any }>; 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/func.get-from-node-element.ts: -------------------------------------------------------------------------------- 1 | import { DebugNode } from '@angular/core'; 2 | 3 | export default (node: DebugNode): DebugNode => 4 | node.nativeNode?.nodeName === '#text' && node.parent ? node.parent : node; 5 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/func.get-last-fixture.ts: -------------------------------------------------------------------------------- 1 | import { ComponentFixture, getTestBed } from '@angular/core/testing'; 2 | 3 | export default () => { 4 | const fixtures: Array> = (getTestBed() as any)._activeFixtures; 5 | 6 | return fixtures[fixtures.length - 1]; 7 | }; 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/func.global-prepare.ts: -------------------------------------------------------------------------------- 1 | import ngMocksUniverse from '../common/ng-mocks-universe'; 2 | 3 | export default () => { 4 | ngMocksUniverse.cacheDeclarations.clear(); 5 | ngMocksUniverse.config.get('ngMocksDepsSkip')?.clear(); 6 | }; 7 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/func.parse-find-args-name.ts: -------------------------------------------------------------------------------- 1 | import { AnyType, DebugNodeSelector } from '../common/core.types'; 2 | import { isNgDef } from '../common/func.is-ng-def'; 3 | 4 | export default (selector: AnyType | DebugNodeSelector): string => { 5 | if (typeof selector === 'string') { 6 | return selector; 7 | } 8 | if (typeof selector === 'function') { 9 | return selector.name; 10 | } 11 | if (isNgDef(selector, 't')) { 12 | return (selector as any)._desc; 13 | } 14 | if (Array.isArray(selector)) { 15 | return selector[0]; 16 | } 17 | if (!selector) { 18 | return ''; 19 | } 20 | 21 | return ''; 22 | }; 23 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.console-ignore.ts: -------------------------------------------------------------------------------- 1 | import helperMockService from '../mock-service/helper.mock-service'; 2 | 3 | import mockHelperConsole from './mock-helper.console'; 4 | 5 | const factory = (propName: string) => helperMockService.mockFunction(`console.${propName}`); 6 | 7 | // Thanks Ivy, it does not throw an error, and we have to use injector. 8 | export default mockHelperConsole(['log'], factory); 9 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.console-throw.ts: -------------------------------------------------------------------------------- 1 | import coreDefineProperty from '../common/core.define-property'; 2 | 3 | import mockHelperConsole from './mock-helper.console'; 4 | 5 | const factory = 6 | (propName: string) => 7 | (...args: any[]) => { 8 | const error = new Error(args.join(' ')); 9 | coreDefineProperty(error, 'ngMocksConsoleCatch', propName); 10 | throw error; 11 | }; 12 | 13 | // Thanks Ivy, it does not throw an error, and we have to use injector. 14 | export default mockHelperConsole(['warn', 'error'], factory); 15 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.default-config.ts: -------------------------------------------------------------------------------- 1 | import { flatten } from '../common/core.helpers'; 2 | import { AnyDeclaration } from '../common/core.types'; 3 | import ngMocksUniverse from '../common/ng-mocks-universe'; 4 | import { IMockBuilderConfig } from '../mock-builder/types'; 5 | 6 | export default ( 7 | def: AnyDeclaration | string | Array | string>, 8 | config?: IMockBuilderConfig, 9 | ): void => { 10 | const map = ngMocksUniverse.getConfigMock(); 11 | for (const item of flatten(def)) { 12 | if (config) { 13 | map.set(item, config); 14 | } else { 15 | map.delete(item); 16 | } 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.default-mock.ts: -------------------------------------------------------------------------------- 1 | import { Injector } from '@angular/core'; 2 | 3 | import { flatten } from '../common/core.helpers'; 4 | import { AnyDeclaration } from '../common/core.types'; 5 | import ngMocksUniverse from '../common/ng-mocks-universe'; 6 | 7 | export default ( 8 | def: AnyDeclaration | string | Array | string>, 9 | callback?: (instance: undefined | T, injector: Injector) => void | Partial, 10 | ): void => { 11 | const map = ngMocksUniverse.getOverrides(); 12 | for (const item of flatten(def)) { 13 | if (callback) { 14 | const set: Set = map.has(item) ? map.get(item) : new Set(); 15 | set.add(callback); 16 | map.set(item, set); 17 | } else { 18 | map.delete(item); 19 | } 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.flush-test-bed.ts: -------------------------------------------------------------------------------- 1 | import { getTestBed } from '@angular/core/testing'; 2 | 3 | export default (): void => { 4 | const testBed: any = getTestBed(); 5 | if (testBed.shouldTearDownTestingModule !== undefined && testBed.shouldTearDownTestingModule()) { 6 | testBed.tearDownTestingModule(); 7 | } 8 | testBed._instantiated = false; 9 | testBed._moduleFactory = undefined; 10 | testBed._testModuleRef = null; 11 | }; 12 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.global-exclude.ts: -------------------------------------------------------------------------------- 1 | import { AnyDeclaration } from '../common/core.types'; 2 | import funcIterateDeclaration from '../common/func.iterate-declaration'; 3 | import ngMocksUniverse from '../common/ng-mocks-universe'; 4 | 5 | import funcGlobalPrepare from './func.global-prepare'; 6 | 7 | const action = (source: AnyDeclaration): void => { 8 | ngMocksUniverse.getDefaults().set(source, ['exclude']); 9 | }; 10 | export default (source: AnyDeclaration, recursively = false): void => { 11 | funcGlobalPrepare(); 12 | action(source); 13 | 14 | if (recursively) { 15 | funcIterateDeclaration(source, action); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.global-keep.ts: -------------------------------------------------------------------------------- 1 | import { AnyDeclaration } from '../common/core.types'; 2 | import funcIterateDeclaration from '../common/func.iterate-declaration'; 3 | import ngMocksUniverse from '../common/ng-mocks-universe'; 4 | 5 | import funcGlobalPrepare from './func.global-prepare'; 6 | 7 | const action = (source: AnyDeclaration): void => { 8 | ngMocksUniverse.getDefaults().set(source, ['keep']); 9 | }; 10 | export default (source: AnyDeclaration, recursively = false): void => { 11 | funcGlobalPrepare(); 12 | action(source); 13 | 14 | if (recursively) { 15 | funcIterateDeclaration(source, action); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.global-mock.ts: -------------------------------------------------------------------------------- 1 | import { AnyDeclaration } from '../common/core.types'; 2 | import funcIterateDeclaration from '../common/func.iterate-declaration'; 3 | import ngMocksUniverse from '../common/ng-mocks-universe'; 4 | 5 | import funcGlobalPrepare from './func.global-prepare'; 6 | 7 | const action = (source: AnyDeclaration): void => { 8 | ngMocksUniverse.getDefaults().set(source, ['mock']); 9 | }; 10 | export default (source: AnyDeclaration, recursively = false): void => { 11 | funcGlobalPrepare(); 12 | action(source); 13 | 14 | if (recursively) { 15 | funcIterateDeclaration(source, action); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.global-wipe.ts: -------------------------------------------------------------------------------- 1 | import { AnyDeclaration } from '../common/core.types'; 2 | import funcIterateDeclaration from '../common/func.iterate-declaration'; 3 | import ngMocksUniverse from '../common/ng-mocks-universe'; 4 | 5 | import funcGlobalPrepare from './func.global-prepare'; 6 | import mockHelperDefaultMock from './mock-helper.default-mock'; 7 | 8 | const action = (source: AnyDeclaration): void => { 9 | ngMocksUniverse.getDefaults().delete(source); 10 | mockHelperDefaultMock(source); 11 | }; 12 | 13 | export default (source: AnyDeclaration, recursively = false): void => { 14 | funcGlobalPrepare(); 15 | action(source); 16 | 17 | if (recursively) { 18 | funcIterateDeclaration(source, action); 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.input.ts: -------------------------------------------------------------------------------- 1 | import mockHelperAttributes from './mock-helper.attributes'; 2 | 3 | export default (...args: any[]) => mockHelperAttributes('input', 'inputs', ...args); 4 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.output.ts: -------------------------------------------------------------------------------- 1 | import mockHelperAttributes from './mock-helper.attributes'; 2 | 3 | export default (...args: any[]) => mockHelperAttributes('output', 'outputs', ...args); 4 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/mock-helper.reset.ts: -------------------------------------------------------------------------------- 1 | import coreConfig from '../common/core.config'; 2 | import ngMocksUniverse from '../common/ng-mocks-universe'; 3 | 4 | export default (): void => { 5 | ngMocksUniverse.builtDeclarations = new Map(); 6 | ngMocksUniverse.builtProviders = new Map(); 7 | ngMocksUniverse.cacheDeclarations = new Map(); 8 | ngMocksUniverse.cacheProviders = new Map(); 9 | ngMocksUniverse.config = new Map(); 10 | ngMocksUniverse.configInstance = new Map(); 11 | ngMocksUniverse.flags = new Set(coreConfig.flags); 12 | ngMocksUniverse.touches = new Set(); 13 | }; 14 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/render/mock-helper.hide.ts: -------------------------------------------------------------------------------- 1 | import funcFindDeep from './func.find-deep'; 2 | import funcParseTemplate from './func.parse-template'; 3 | 4 | export default (instance: object, param?: object) => { 5 | const template = param ? funcParseTemplate(param) : undefined; 6 | 7 | let result = false; 8 | funcFindDeep( 9 | instance, 10 | tpl => { 11 | if (!template) { 12 | return true; 13 | } 14 | 15 | return tpl.elementRef.nativeElement === template.elementRef.nativeElement; 16 | }, 17 | vcr => { 18 | vcr.clear(); 19 | result = true; 20 | 21 | return false; 22 | }, 23 | ); 24 | 25 | if (!result) { 26 | throw new Error('Cannot find path to the TemplateRef'); 27 | } 28 | }; 29 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/render/mock-helper.render.ts: -------------------------------------------------------------------------------- 1 | import funcFindDeep from './func.find-deep'; 2 | import funcParseTemplate from './func.parse-template'; 3 | 4 | export default (instance: object, param: object, $implicit?: any, variables?: Record) => { 5 | const template = funcParseTemplate(param); 6 | 7 | const result = funcFindDeep( 8 | instance, 9 | tpl => tpl.elementRef.nativeElement === template.elementRef.nativeElement, 10 | (vcr, tpl) => { 11 | const context = { 12 | ...variables, 13 | $implicit, 14 | }; 15 | vcr.clear(); 16 | vcr.createEmbeddedView(tpl, context).detectChanges(); 17 | 18 | return true; 19 | }, 20 | ); 21 | 22 | if (!result) { 23 | throw new Error('Cannot find path to the TemplateRef'); 24 | } 25 | }; 26 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-helper/template-ref/func.is-valid-template-ref-selector.ts: -------------------------------------------------------------------------------- 1 | export default (value: any): boolean => { 2 | if (typeof value === 'string') { 3 | return true; 4 | } 5 | if (Array.isArray(value) && typeof value[0] === 'string') { 6 | return true; 7 | } 8 | if (typeof value === 'function') { 9 | return true; 10 | } 11 | 12 | return false; 13 | }; 14 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-instance/mock-instance-apply.ts: -------------------------------------------------------------------------------- 1 | import ngMocksUniverse from '../common/ng-mocks-universe'; 2 | import mockHelperStubMember from '../mock-helper/mock-helper.stub-member'; 3 | 4 | export default (def: any): any[] => { 5 | const callbacks = []; 6 | 7 | const config = ngMocksUniverse.configInstance.get(def); 8 | if (config?.overloads) { 9 | for (const [name, stub, encapsulation] of config.overloads) { 10 | if (name) { 11 | callbacks.push((instance: any) => { 12 | mockHelperStubMember(instance, name, stub, encapsulation); 13 | }); 14 | } else { 15 | callbacks.push(stub); 16 | } 17 | } 18 | } 19 | 20 | return callbacks; 21 | }; 22 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-module/mark-providers.ts: -------------------------------------------------------------------------------- 1 | import { flatten } from '../common/core.helpers'; 2 | import funcGetType from '../common/func.get-type'; 3 | import markExported from '../mock/mark-exported'; 4 | 5 | export default (providers?: any[]): void => { 6 | for (const provider of flatten(providers ?? [])) { 7 | const instance = funcGetType(provider); 8 | markExported(instance); 9 | } 10 | }; 11 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-module/providers.spec.ts: -------------------------------------------------------------------------------- 1 | import { Injectable, NgModule } from '@angular/core'; 2 | 3 | import { isMockedNgDefOf } from '../common/func.is-mocked-ng-def-of'; 4 | 5 | import { MockModule } from './mock-module'; 6 | 7 | @Injectable() 8 | class TargetService {} 9 | 10 | @NgModule({ 11 | providers: [TargetService], 12 | }) 13 | class Target1Module {} 14 | 15 | @NgModule({ 16 | providers: [TargetService], 17 | }) 18 | class Target2Module {} 19 | 20 | describe('MockProvider', () => { 21 | it('reuses mock for services', () => { 22 | const mock1 = MockModule(Target1Module); 23 | const mock2 = MockModule(Target2Module); 24 | expect(isMockedNgDefOf(mock1, Target1Module, 'm')).toBeTruthy(); 25 | expect(isMockedNgDefOf(mock2, Target2Module, 'm')).toBeTruthy(); 26 | }); 27 | }); 28 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-module/types.ts: -------------------------------------------------------------------------------- 1 | import { Mock } from '../common/mock'; 2 | 3 | /** 4 | * MockedModule is a legacy representation of an interface of a mock module instance. 5 | * Please avoid its usage, because, usually, you should not rely on whether it's a mock or not. 6 | */ 7 | export type MockedModule = T & Mock; 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-pipe/types.ts: -------------------------------------------------------------------------------- 1 | // istanbul ignore file 2 | 3 | import { Mock } from '../common/mock'; 4 | 5 | /** 6 | * MockedPipe is a legacy representation of an interface of a mock pipe instance. 7 | * Please avoid its usage, because, usually, you should not rely on whether it's a mock or not. 8 | */ 9 | export type MockedPipe = T & Mock; 10 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-service/check.is-class.ts: -------------------------------------------------------------------------------- 1 | import checkIsFunc from './check.is-func'; 2 | 3 | export default (value: any): boolean => { 4 | if (typeof value !== 'function') { 5 | return false; 6 | } 7 | 8 | return !checkIsFunc(value); 9 | }; 10 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-service/check.is-inst.ts: -------------------------------------------------------------------------------- 1 | export default (value: any): boolean => { 2 | if (value === null) { 3 | return false; 4 | } 5 | if (typeof value !== 'object') { 6 | return false; 7 | } 8 | if (value.ngMetadataName === 'InjectionToken') { 9 | return false; 10 | } 11 | 12 | return typeof Object.getPrototypeOf(value) === 'object'; 13 | }; 14 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-service/helper.extract-properties-from-prototype.ts: -------------------------------------------------------------------------------- 1 | export default (service: T): string[] => { 2 | const result: string[] = []; 3 | let prototype = service; 4 | while (prototype && Object.getPrototypeOf(prototype) !== null) { 5 | for (const prop of Object.getOwnPropertyNames(prototype)) { 6 | if ((prop as any) === 'constructor') { 7 | continue; 8 | } 9 | 10 | const descriptor = Object.getOwnPropertyDescriptor(prototype, prop); 11 | const isGetterSetter = descriptor && (descriptor.get || descriptor.set); 12 | if (!isGetterSetter || result.indexOf(prop) !== -1) { 13 | continue; 14 | } 15 | result.push(prop); 16 | } 17 | prototype = Object.getPrototypeOf(prototype); 18 | } 19 | 20 | return result; 21 | }; 22 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-service/helper.extract-property-descriptor.spec.ts: -------------------------------------------------------------------------------- 1 | import helperExtractPropertyDescriptor from './helper.extract-property-descriptor'; 2 | 3 | describe('helper.extract-property-descriptor', () => { 4 | it('returns undefined on null', () => { 5 | expect( 6 | helperExtractPropertyDescriptor(null, 'test'), 7 | ).toBeUndefined(); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-service/helper.extract-property-descriptor.ts: -------------------------------------------------------------------------------- 1 | export default (service: T, prop: keyof any): PropertyDescriptor | undefined => { 2 | let prototype = service; 3 | while (prototype && Object.getPrototypeOf(prototype) !== null) { 4 | const descriptor = Object.getOwnPropertyDescriptor(prototype, prop); 5 | if (descriptor) { 6 | return descriptor; 7 | } 8 | prototype = Object.getPrototypeOf(prototype); 9 | } 10 | 11 | return undefined; 12 | }; 13 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock-service/types.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * MockedFunction describes the interface of a function which can be used as a spy. 3 | * For example, jasmine.createSpy() and jest.fn() are MockedFunction. 4 | * 5 | * @see https://ng-mocks.sudo.eu/extra/auto-spy 6 | */ 7 | export type MockedFunction = (...args: any[]) => any; 8 | 9 | /** 10 | * CustomMockFunction describes the interface of a factory which should produce MockFunction. 11 | * It accepts a label / name and should return a spy / mock function. 12 | * 13 | * @see https://ng-mocks.sudo.eu/extra/auto-spy 14 | */ 15 | export type CustomMockFunction = (mockName: string) => MockedFunction; 16 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock/mark-exported.ts: -------------------------------------------------------------------------------- 1 | import { getSourceOfMock } from '../common/func.get-source-of-mock'; 2 | import ngMocksUniverse from '../common/ng-mocks-universe'; 3 | 4 | export default (instanceDef: any, ngModuleDef?: any) => { 5 | const instance = getSourceOfMock(instanceDef); 6 | const configInstance = ngMocksUniverse.configInstance.get(instance) ?? { __set: true }; 7 | if (!configInstance.exported) { 8 | configInstance.exported = new Set(); 9 | } 10 | if (ngModuleDef) { 11 | configInstance.exported.add(getSourceOfMock(ngModuleDef)); 12 | } 13 | if (configInstance.__set) { 14 | configInstance.__set = undefined; 15 | ngMocksUniverse.configInstance.set(instance, configInstance); 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock/return-cached-mock.ts: -------------------------------------------------------------------------------- 1 | import { NG_MOCKS } from '../common/core.tokens'; 2 | import ngMocksUniverse from '../common/ng-mocks-universe'; 3 | import funcGetLastFixture from '../mock-helper/func.get-last-fixture'; 4 | 5 | export default (declaration: any) => { 6 | let result: any; 7 | 8 | try { 9 | result = funcGetLastFixture().debugElement.injector.get(NG_MOCKS).get(declaration); 10 | } catch { 11 | // nothing to do. 12 | } 13 | 14 | if (!result) { 15 | result = ngMocksUniverse.cacheDeclarations.get(declaration); 16 | } 17 | 18 | if (declaration.__ngMocksResolutions && ngMocksUniverse.config.has('mockNgDefResolver')) { 19 | ngMocksUniverse.config.get('mockNgDefResolver').merge(declaration.__ngMocksResolutions); 20 | } 21 | 22 | return result; 23 | }; 24 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock/to-existing-provider.ts: -------------------------------------------------------------------------------- 1 | import { AnyType } from '../common/core.types'; 2 | 3 | export default (provide: AnyType, useExisting: AnyType) => ({ 4 | provide, 5 | useExisting, 6 | }); 7 | -------------------------------------------------------------------------------- /libs/ng-mocks/src/lib/mock/to-factory-provider.ts: -------------------------------------------------------------------------------- 1 | import { AnyType } from '../common/core.types'; 2 | 3 | export default (provide: AnyType, useFactory: any) => ({ 4 | multi: true, 5 | provide, 6 | useFactory, 7 | }); 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/tsconfig.build.mjs.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.cjs.json", 3 | "compilerOptions": { 4 | "module": "ES2015", 5 | "target": "ES2015" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /libs/ng-mocks/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.cjs.json", 3 | "compilerOptions": { 4 | "experimentalDecorators": true 5 | }, 6 | "include": ["./src/lib/**/*.ts"] 7 | } 8 | -------------------------------------------------------------------------------- /tests-e2e/.browserslistrc: -------------------------------------------------------------------------------- 1 | last 1 Chrome version 2 | last 1 Firefox version 3 | last 2 Edge major versions 4 | last 2 Safari major versions 5 | last 2 iOS major versions 6 | Firefox ESR 7 | -------------------------------------------------------------------------------- /tests-e2e/.gitignore: -------------------------------------------------------------------------------- 1 | /dist 2 | /node_modules 3 | /src/test 4 | -------------------------------------------------------------------------------- /tests-e2e/.nvmrc: -------------------------------------------------------------------------------- 1 | 22.15.1 2 | -------------------------------------------------------------------------------- /tests-e2e/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { ChangeDetectionStrategy, Component } from '@angular/core'; 2 | 3 | @Component( 4 | { 5 | selector: 'app-root', 6 | standalone: false, 7 | template: 'ng-mocks: {{ title }}', 8 | changeDetection: ChangeDetectionStrategy.OnPush, 9 | } as never /* TODO: remove after upgrade to a14 */, 10 | ) 11 | export class AppComponent { 12 | public readonly title: string = 'hello'; 13 | 14 | public appComponent() {} 15 | } 16 | -------------------------------------------------------------------------------- /tests-e2e/src/app/app.directive.ts: -------------------------------------------------------------------------------- 1 | import { Directive } from '@angular/core'; 2 | 3 | @Directive( 4 | { 5 | selector: 'app-root', 6 | standalone: false, 7 | } as never /* TODO: remove after upgrade to a14 */, 8 | ) 9 | export class AppDirective { 10 | public appDirective() {} 11 | } 12 | -------------------------------------------------------------------------------- /tests-e2e/src/app/app.pipe.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | @Pipe( 4 | { 5 | name: 'app', 6 | standalone: false, 7 | } as never /* TODO: remove after upgrade to a14 */, 8 | ) 9 | export class AppPipe implements PipeTransform { 10 | transform(): string { 11 | return this.constructor.name; 12 | } 13 | 14 | public appPipe() {} 15 | } 16 | -------------------------------------------------------------------------------- /tests-e2e/src/app/app.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | 3 | @Injectable() 4 | export class AppService { 5 | public appService() {} 6 | } 7 | -------------------------------------------------------------------------------- /tests-e2e/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Angular Minimal Dependencies 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /tests-e2e/src/issue-4693/child.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | standalone: true, 5 | selector: 'child', 6 | template: 'child', 7 | }) 8 | export class ChildComponent { 9 | public childComponent4693() {} 10 | } 11 | -------------------------------------------------------------------------------- /tests-e2e/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | enableProdMode(); 6 | 7 | platformBrowserDynamic() 8 | .bootstrapModule(AppModule) 9 | .catch(error => console.error(error)); 10 | -------------------------------------------------------------------------------- /tests-e2e/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import { getTestBed } from '@angular/core/testing'; 4 | import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; 5 | 6 | // Initialize the Angular testing environment. 7 | getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), { 8 | errorOnUnknownElements: true, 9 | errorOnUnknownProperties: true, 10 | }); 11 | -------------------------------------------------------------------------------- /tests-failures/get-mocked-ng-def-of.ts: -------------------------------------------------------------------------------- 1 | import { getMockedNgDefOf } from 'ng-mocks'; 2 | import { Type } from '@angular/core'; 3 | 4 | declare class Expected { 5 | public name: string; 6 | } 7 | 8 | declare class Actual { 9 | public name: number; 10 | } 11 | 12 | declare let result1: Type; 13 | declare let result2: Type; 14 | 15 | // @ts-expect-error: string is not boolean 16 | result1 = getMockedNgDefOf(Expected); 17 | 18 | // boolean is boolean 19 | result2 = getMockedNgDefOf(Expected); 20 | -------------------------------------------------------------------------------- /tests-failures/mock-component.ts: -------------------------------------------------------------------------------- 1 | import { MockComponent, MockComponents } from 'ng-mocks'; 2 | 3 | class MyComponent {} 4 | 5 | abstract class AbstractComponent {} 6 | 7 | // Any class works well. 8 | MockComponent(MyComponent); 9 | MockComponents(MyComponent); 10 | 11 | // @ts-expect-error: does not accept an abstract component. 12 | MockComponent(AbstractComponent); 13 | 14 | // @ts-expect-error: does not accept an abstract component. 15 | MockComponents(AbstractComponent); 16 | -------------------------------------------------------------------------------- /tests-failures/mock-directive.ts: -------------------------------------------------------------------------------- 1 | import { MockDirective, MockDirectives } from 'ng-mocks'; 2 | 3 | class MyDirective {} 4 | 5 | abstract class AbstractDirective {} 6 | 7 | // Any class works well. 8 | MockDirective(MyDirective); 9 | MockDirectives(MyDirective); 10 | 11 | // @ts-expect-error: does not accept an abstract directive. 12 | MockDirective(AbstractDirective); 13 | 14 | // @ts-expect-error: does not accept an abstract directive. 15 | MockDirectives(AbstractDirective); 16 | -------------------------------------------------------------------------------- /tests-failures/mock-instance-token.ts: -------------------------------------------------------------------------------- 1 | import { InjectionToken } from '@angular/core'; 2 | 3 | import { MockInstance } from 'ng-mocks'; 4 | 5 | const TOKEN = new InjectionToken<{ prop: boolean }>('TOKEN'); 6 | 7 | // Accepts valid type. 8 | MockInstance(TOKEN, () => ({ 9 | prop: true, 10 | })); 11 | // Accepts valid type. 12 | MockInstance(TOKEN, { 13 | init: () => ({ 14 | prop: false, 15 | }), 16 | }); 17 | // Accepts reset. 18 | MockInstance(TOKEN); 19 | 20 | // @ts-expect-error: does not support wrong types. 21 | MockInstance(TOKEN, () => true); 22 | // @ts-expect-error: does not support wrong types. 23 | MockInstance(TOKEN, () => ({ 24 | prop: 123, 25 | })); 26 | // @ts-expect-error: does not support wrong types. 27 | MockInstance(TOKEN, { 28 | init: () => ({ 29 | prop: 123, 30 | }), 31 | }); 32 | -------------------------------------------------------------------------------- /tests-failures/mock-module.ts: -------------------------------------------------------------------------------- 1 | import { MockModule } from 'ng-mocks'; 2 | 3 | class MyModule {} 4 | 5 | abstract class AbstractModule {} 6 | 7 | const moduleWithProviders = { 8 | ngModule: MyModule, 9 | providers: [], 10 | }; 11 | 12 | const abstractModuleWithProviders = { 13 | ngModule: AbstractModule, 14 | providers: [], 15 | }; 16 | 17 | // Any class works well. 18 | MockModule(MyModule); 19 | 20 | // A module with providers works well. 21 | MockModule(moduleWithProviders); 22 | 23 | // @ts-expect-error: does not accept an abstract module. 24 | MockModule(AbstractModule); 25 | 26 | // @ts-expect-error: does not accept an abstract module with providers. 27 | MockModule(abstractModuleWithProviders); 28 | -------------------------------------------------------------------------------- /tests/injected-ng-templates/fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Component, ContentChild, Input, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'custom-injection', 5 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 6 | template: ` 7 |
8 | 9 |
10 |
11 | `, 12 | }) 13 | export class CustomInjectionComponent { 14 | @ContentChild('block', {} as never) public injectedBlock?: TemplateRef; 15 | @Input() public items?: T[]; 16 | @ViewChild('child', {} as never) public ownChild?: ViewContainerRef; 17 | } 18 | -------------------------------------------------------------------------------- /tests/issue-151/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | 4 | import { HelloComponent } from './hello.component'; 5 | import { HelloModule } from './hello.module'; 6 | 7 | const routes: Routes = [ 8 | { 9 | path: '', 10 | pathMatch: 'full', 11 | redirectTo: '/hello', 12 | }, 13 | { 14 | component: HelloComponent, 15 | path: 'hello', 16 | }, 17 | ]; 18 | 19 | @NgModule({ 20 | exports: [HelloModule, RouterModule], 21 | imports: [HelloModule, RouterModule.forRoot(routes)], 22 | }) 23 | export class AppRoutingModule {} 24 | -------------------------------------------------------------------------------- /tests/issue-151/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-151', 5 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 6 | template: '', 7 | }) 8 | export class AppComponent {} 9 | -------------------------------------------------------------------------------- /tests/issue-151/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | 7 | @NgModule({ 8 | bootstrap: [AppComponent], 9 | declarations: [AppComponent], 10 | imports: [BrowserModule, AppRoutingModule], 11 | }) 12 | export class AppModule {} 13 | -------------------------------------------------------------------------------- /tests/issue-151/app/hello.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'hello-151', 5 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 6 | template: 'hello', 7 | }) 8 | export class HelloComponent {} 9 | -------------------------------------------------------------------------------- /tests/issue-151/app/hello.module.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { NgModule } from '@angular/core'; 3 | 4 | import { HelloComponent } from './hello.component'; 5 | 6 | @NgModule({ 7 | declarations: [HelloComponent], 8 | exports: [HelloComponent], 9 | imports: [CommonModule], 10 | }) 11 | export class HelloModule {} 12 | -------------------------------------------------------------------------------- /tests/issue-197/abstract.spec.ts: -------------------------------------------------------------------------------- 1 | import { DomSanitizer } from '@angular/platform-browser'; 2 | 3 | import { MockBuilder, ngMocks } from 'ng-mocks'; 4 | 5 | // @see https://github.com/help-me-mom/ng-mocks/issues/197 6 | describe('issue-197:abstract', () => { 7 | const expected = {}; 8 | beforeEach(() => { 9 | return MockBuilder().mock(DomSanitizer, expected, { 10 | precise: true, 11 | }); 12 | }); 13 | 14 | it('mocks abstract classes', () => { 15 | const actual = ngMocks.findInstance(DomSanitizer); 16 | expect(actual).toBe(expected); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /tests/issue-222/application-module.spec.ts: -------------------------------------------------------------------------------- 1 | import { ApplicationRef, NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { MockBuilder, ngMocks } from 'ng-mocks'; 5 | 6 | @NgModule({ 7 | imports: [BrowserModule], 8 | }) 9 | class TargetModule {} 10 | 11 | // @see https://github.com/help-me-mom/ng-mocks/issues/222 12 | describe('issue-222:application-module', () => { 13 | beforeEach(() => MockBuilder(null, TargetModule)); 14 | 15 | it('does not mock its guts', () => { 16 | const service = ngMocks.findInstance(ApplicationRef); 17 | expect(service.viewCount).toBeDefined(); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /tests/issue-241/test.builder.spec.ts: -------------------------------------------------------------------------------- 1 | import { MockBuilder, MockRender } from 'ng-mocks'; 2 | 3 | import { AppModule, TargetComponent } from './fixtures'; 4 | 5 | // @see https://github.com/help-me-mom/ng-mocks/issues/241 6 | describe('issue-241:builder', () => { 7 | beforeEach(() => MockBuilder(TargetComponent, AppModule)); 8 | 9 | it('it exports pipe', () => { 10 | const fixture = MockRender(TargetComponent); 11 | 12 | // A mock pipe returns nothing. 13 | expect(fixture.nativeElement.innerHTML).toEqual( 14 | '', 15 | ); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /tests/issue-241/test.classic.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { MockModule, MockRender } from 'ng-mocks'; 4 | 5 | import { AppModule, TargetComponent } from './fixtures'; 6 | 7 | // @see https://github.com/help-me-mom/ng-mocks/issues/241 8 | describe('issue-241:classic', () => { 9 | beforeEach(() => 10 | TestBed.configureTestingModule({ 11 | imports: [MockModule(AppModule)], 12 | }).compileComponents(), 13 | ); 14 | 15 | it('it exports pipe', () => { 16 | const fixture = MockRender(TargetComponent); 17 | 18 | // A mock pipe returns nothing. 19 | expect(fixture.nativeElement.innerHTML).toEqual( 20 | '', 21 | ); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /tests/issue-241/test.guts.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { MockRender, ngMocks } from 'ng-mocks'; 4 | 5 | import { AppModule, TargetComponent } from './fixtures'; 6 | 7 | // @see https://github.com/help-me-mom/ng-mocks/issues/241 8 | describe('issue-241:guts', () => { 9 | beforeEach(() => 10 | TestBed.configureTestingModule( 11 | ngMocks.guts(TargetComponent, AppModule), 12 | ).compileComponents(), 13 | ); 14 | 15 | it('it exports pipe', () => { 16 | const fixture = MockRender(TargetComponent); 17 | 18 | // A mock pipe returns nothing. 19 | expect(fixture.nativeElement.innerHTML).toEqual( 20 | '', 21 | ); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /tests/issue-241/test.real.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { MockRender } from 'ng-mocks'; 4 | 5 | import { AppModule, TargetComponent } from './fixtures'; 6 | 7 | // @see https://github.com/help-me-mom/ng-mocks/issues/241 8 | describe('issue-241:real', () => { 9 | beforeEach(() => 10 | TestBed.configureTestingModule({ 11 | imports: [AppModule], 12 | }).compileComponents(), 13 | ); 14 | 15 | it('it exports pipe', () => { 16 | const fixture = MockRender(TargetComponent); 17 | 18 | // A real pipe returns the string's length. 19 | expect(fixture.nativeElement.innerHTML).toEqual( 20 | '6', 21 | ); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /tests/issue-3811/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { MockRender } from 'ng-mocks'; 2 | 3 | // we need to ensure that MockRender component provides correct access to the __ngContext__ property. 4 | describe('issue-3811', () => { 5 | it('provides access to __ngContext__', () => { 6 | const fixture = MockRender(''); 7 | const ngContext = (fixture.componentInstance as any) 8 | .__ngContext__; 9 | expect(ngContext).toBeDefined(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /tests/issue-567/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { Component, ContentChild, TemplateRef } from '@angular/core'; 2 | 3 | import { MockBuilder, MockRender } from 'ng-mocks'; 4 | 5 | @Component({ 6 | selector: 'target-567', 7 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: 8 | false, 9 | template: '', 10 | }) 11 | class TargetComponent { 12 | @ContentChild('s-e_-_ri23sTo 12 o#ltTem_~_plate_', {} as never) 13 | public readonly seriesTooltipTemplate?: TemplateRef; 14 | } 15 | 16 | // @see https://github.com/help-me-mom/ng-mocks/issues/567 17 | describe('issue-567', () => { 18 | beforeEach(() => MockBuilder(null, TargetComponent)); 19 | 20 | it('does not fail on seriesTooltipTemplate', () => { 21 | expect(() => MockRender(TargetComponent)).not.toThrow(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /tests/mock-builder-keeps-application-module/fixtures.ts: -------------------------------------------------------------------------------- 1 | import { APP_INITIALIZER, Component, InjectionToken, NgModule } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'target-component', 5 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 6 | template: 'target', 7 | }) 8 | export class TargetComponent {} 9 | 10 | export const TARGET_TOKEN = new InjectionToken('TARGET_TOKEN'); 11 | 12 | @NgModule({ 13 | declarations: [TargetComponent], 14 | exports: [TargetComponent], 15 | providers: [ 16 | { 17 | provide: TARGET_TOKEN, 18 | useValue: 'TARGET_TOKEN', 19 | }, 20 | { 21 | multi: true, 22 | provide: APP_INITIALIZER, 23 | useValue: () => undefined, 24 | }, 25 | ], 26 | }) 27 | export class TargetModule {} 28 | -------------------------------------------------------------------------------- /tests/mock-component/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { MockComponent } from 'ng-mocks'; 4 | 5 | @Component({ 6 | selector: 'target-mock-component', 7 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: 8 | false, 9 | template: 'target', 10 | }) 11 | class TargetComponent {} 12 | 13 | describe('MockComponent', () => { 14 | it('reuses mocks', () => { 15 | const expected = MockComponent(TargetComponent); 16 | const actual = MockComponent(TargetComponent); 17 | expect(actual).toBe(expected); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /tests/mock-service-override/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { MockService } from 'ng-mocks'; 2 | 3 | describe('mock-service-override', () => { 4 | class MyClass { 5 | protected name = 'real'; 6 | 7 | public echo1(): string { 8 | return this.name; 9 | } 10 | 11 | public echo2(): string { 12 | return this.name; 13 | } 14 | } 15 | 16 | it('overrides partially', () => { 17 | const instance = MockService(MyClass, { echo2: () => 'mock' }); 18 | expect(instance.echo1()).toBeUndefined(); 19 | expect(instance.echo2()).toEqual('mock'); 20 | }); 21 | }); 22 | -------------------------------------------------------------------------------- /tests/mock-service/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { MockService } from 'ng-mocks'; 2 | 3 | describe('mock-service', () => { 4 | it('detects unnamed classes', () => { 5 | const instance = MockService( 6 | class { 7 | private readonly value = 'unnamed'; 8 | 9 | public echo1() { 10 | return this.value; 11 | } 12 | }, 13 | ); 14 | expect(instance.echo1()).toBeUndefined(); 15 | }); 16 | 17 | it('adds prefixes', () => { 18 | const instance = MockService( 19 | class { 20 | private readonly value = 'unnamed'; 21 | 22 | public echo1() { 23 | return this.value; 24 | } 25 | }, 26 | 'prefix', 27 | ); 28 | expect(instance.echo1()).toBeUndefined(); 29 | }); 30 | }); 31 | -------------------------------------------------------------------------------- /tests/ng-mocks-find-all/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { MockRender, ngMocks } from 'ng-mocks'; 2 | 3 | describe('ng-mocks-find-all', () => { 4 | it('find attributes', () => { 5 | const fixture = MockRender( 6 | '
', 7 | ); 8 | 9 | const [el1] = ngMocks.findAll(['data-1', 1]); 10 | const [el2] = ngMocks.findAll(fixture, ['data-2', 'test']); 11 | const [el3] = ngMocks.findAll(fixture.debugElement, ['data-3']); 12 | 13 | expect(el1).toBeDefined(); 14 | expect(el1).toEqual(el2); 15 | expect(el1).toEqual(el3); 16 | }); 17 | }); 18 | -------------------------------------------------------------------------------- /tests/ng-mocks-find-instance/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { ngMocks } from 'ng-mocks'; 2 | 3 | describe('ng-mocks-find-instance', () => { 4 | it('fails on wrong types', () => { 5 | expect(() => ngMocks.findInstance(123 as any)).toThrowError( 6 | 'Only classes or tokens are accepted', 7 | ); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /tests/ng-mocks-find-instances/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { ngMocks } from 'ng-mocks'; 2 | 3 | describe('ng-mocks-find-instances', () => { 4 | it('fails on wrong types', () => { 5 | expect(() => ngMocks.findInstances(123 as any)).toThrowError( 6 | 'Only classes or tokens are accepted', 7 | ); 8 | }); 9 | }); 10 | -------------------------------------------------------------------------------- /tests/pipe-auto-spy/test.spec.ts: -------------------------------------------------------------------------------- 1 | import { Pipe, PipeTransform } from '@angular/core'; 2 | 3 | import { MockBuilder, MockRender, ngMocks } from 'ng-mocks'; 4 | 5 | @Pipe({ 6 | name: 'target', 7 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: 8 | false, 9 | }) 10 | class TargetPipe implements PipeTransform { 11 | public transform(value: string): number { 12 | return value.length; 13 | } 14 | } 15 | 16 | describe('pipe-auto-spy', () => { 17 | beforeEach(() => MockBuilder(null, TargetPipe)); 18 | 19 | it('has spy out of the box', () => { 20 | MockRender("{{ 'test' | target }}"); 21 | const pipe = ngMocks.findInstance(TargetPipe); 22 | expect(pipe.transform).toHaveBeenCalledWith('test'); 23 | expect(pipe.transform).toHaveBeenCalledTimes(1); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/rerender-rendered-content-child/fixtures.ts: -------------------------------------------------------------------------------- 1 | import { CommonModule } from '@angular/common'; 2 | import { Component, ContentChild, NgModule, TemplateRef } from '@angular/core'; 3 | 4 | @Component({ 5 | selector: 'ccc', 6 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 7 | template: '', 8 | }) 9 | export class ContentChildComponent { 10 | @ContentChild('block', {} as never) public injectedBlock?: TemplateRef; 11 | } 12 | 13 | @NgModule({ 14 | declarations: [ContentChildComponent], 15 | exports: [ContentChildComponent], 16 | imports: [CommonModule], 17 | }) 18 | export class ContentChildModule {} 19 | -------------------------------------------------------------------------------- /tests/structural-directives/spec.custom-ng-if.directive.fixtures.ts: -------------------------------------------------------------------------------- 1 | import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core'; 2 | 3 | @Directive({ 4 | selector: '[customNgIf]', 5 | ['standalone' as never /* TODO: remove after upgrade to a14 */]: false, 6 | }) 7 | export class CustomNgIfDirective { 8 | public constructor( 9 | protected templateRef: TemplateRef, 10 | protected viewContainerRef: ViewContainerRef, 11 | ) {} 12 | 13 | @Input('customNgIf') public set setValue(value: any) { 14 | if (value) { 15 | this.viewContainerRef.createEmbeddedView(this.templateRef); 16 | } else { 17 | this.viewContainerRef.clear(); 18 | } 19 | } 20 | } 21 | --------------------------------------------------------------------------------