{"_id":"@bobbyg603/ng-mocks","_rev":"1-cf920714498d781b37b6780ee9928538","name":"@bobbyg603/ng-mocks","dist-tags":{"latest":"14.14.0"},"versions":{"14.13.2":{"name":"@bobbyg603/ng-mocks","version":"14.13.2","keywords":["angular","test","testing","mock","mocking","component","directive","pipe","provider","service","TestBed","how-to","frontend","front-end","jest","jasmine","enzyme","stub","dependency"],"author":{"url":"https://github.com/ike18t","name":"Isaac Datlof","email":"ike18t@gmail.com"},"license":"MIT","_id":"@bobbyg603/ng-mocks@14.13.2","maintainers":[{"name":"bobbyg603","email":"bobbyg603@gmail.com"}],"homepage":"https://ng-mocks.sudo.eu","bugs":{"url":"https://github.com/help-me-mom/ng-mocks/issues"},"dist":{"shasum":"d851ea6512040504fa07df69171f72da003eeb1c","tarball":"https://registry.npmjs.org/@bobbyg603/ng-mocks/-/ng-mocks-14.13.2.tgz","fileCount":10,"integrity":"sha512-Yaw67ESYwRmQb3yHL9novatSIJQ9hX9wt0RcXcsLnvX9Jk4R+ySOwDpyKnkrdtv/ZsMLn+EpozFa2LH+rBTWkg==","signatures":[{"sig":"MEYCIQDAsG17qmwpPnthF+mMJLvk3DsXiAXtOZWFcaygp8xswwIhAOxdqELBwH3vR1uX1/tVO6Y791vItVUgtKx+/mNxSVzm","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1687132},"main":"./index.js","type":"commonjs","_from":"file:tmp/bobbyg603-ng-mocks-14.13.2.tgz","types":"./index.d.ts","exports":{".":{"types":"./index.d.ts","import":"./index.mjs","default":"./index.js","require":"./index.js"},"./package.json":"./package.json"},"funding":"https://github.com/sponsors/help-me-mom","scripts":{"test":"karma start"},"_npmUser":{"name":"bobbyg603","email":"bobbyg603@gmail.com"},"standard":{},"_resolved":"/Users/bobby/Desktop/bugsplat/ng-mocks/tmp/bobbyg603-ng-mocks-14.13.2.tgz","ng-update":{"migrations":"./migrations.json"},"_integrity":"sha512-Yaw67ESYwRmQb3yHL9novatSIJQ9hX9wt0RcXcsLnvX9Jk4R+ySOwDpyKnkrdtv/ZsMLn+EpozFa2LH+rBTWkg==","repository":{"url":"git+https://github.com/help-me-mom/ng-mocks.git","type":"git"},"_npmVersion":"10.9.0","description":"An Angular testing library for creating mock services, components, directives, pipes and modules in unit tests. It provides shallow rendering, precise stubs to fake child dependencies. ng-mocks works with Angular 5 6 7 8 9 10 11 12 13 14 15 16 17 18, jasm","directories":{},"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"peerDependencies":{"@angular/core":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18","@angular/forms":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18","@angular/common":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18","@angular/platform-browser":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18"},"_npmOperationalInternal":{"tmp":"tmp/ng-mocks_14.13.2_1735666309846_0.13405823286329954","host":"s3://npm-registry-packages-npm-production"}},"14.14.0":{"name":"@bobbyg603/ng-mocks","version":"14.14.0","description":"An Angular testing library for creating mock services, components, directives, pipes and modules in unit tests. It provides shallow rendering, precise stubs to fake child dependencies. ng-mocks works with Angular 5 6 7 8 9 10 11 12 13 14 15 16 17 18, jasm","keywords":["angular","test","testing","mock","mocking","component","directive","pipe","provider","service","TestBed","how-to","frontend","front-end","jest","jasmine","enzyme","stub","dependency"],"funding":"https://github.com/sponsors/help-me-mom","author":{"name":"Isaac Datlof","email":"ike18t@gmail.com","url":"https://github.com/ike18t"},"maintainers":[{"name":"bobbyg603","email":"bobbyg603@gmail.com"}],"repository":{"type":"git","url":"git+https://github.com/help-me-mom/ng-mocks.git"},"bugs":{"url":"https://github.com/help-me-mom/ng-mocks/issues"},"homepage":"https://ng-mocks.sudo.eu","license":"MIT","types":"./index.d.ts","main":"./index.js","type":"commonjs","exports":{".":{"types":"./index.d.ts","require":"./index.js","import":"./index.mjs","default":"./index.js"},"./package.json":"./package.json"},"ng-update":{"migrations":"./migrations.json"},"standard":{},"scripts":{"test":"karma start"},"peerDependencies":{"@angular/common":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18 || 19.0.0-alpha - 19","@angular/core":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18 || 19.0.0-alpha - 19","@angular/forms":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18 || 19.0.0-alpha - 19","@angular/platform-browser":"5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14 || 15.0.0-alpha - 15 || 16.0.0-alpha - 16 || 17.0.0-alpha - 17 || 18.0.0-alpha - 18 || 19.0.0-alpha - 19"},"_id":"@bobbyg603/ng-mocks@14.14.0","gitHead":"d34680049b3abed53e51343f4978e387597c3f88","_nodeVersion":"22.11.0","_npmVersion":"11.1.0","dist":{"integrity":"sha512-5yjq9iKXjpQl2Rrmtx1zuE/MHiZeBC1MZ3V0yel5RhPKpgQGuVkevFl1hLLFQQJq04rEji4WYa7YiQJ4JSLm4w==","shasum":"7dc1806dea6860add18ee49d20d75144dbf39beb","tarball":"https://registry.npmjs.org/@bobbyg603/ng-mocks/-/ng-mocks-14.14.0.tgz","fileCount":10,"unpackedSize":1693787,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDdx5n7ORPtRPxcuBO1c8UreaQBTht4SacUXqZtVnBBHQIgRX/l8xOlqaEZStAepWtyRBDV+FbVUe20Qi4WzxVCmog="}]},"_npmUser":{"name":"bobbyg603","email":"bobbyg603@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ng-mocks_14.14.0_1738622020800_0.9314292720135717"},"_hasShrinkwrap":false}},"time":{"created":"2024-12-31T17:31:49.727Z","modified":"2025-02-03T22:33:41.221Z","14.13.2":"2024-12-31T17:31:50.320Z","14.14.0":"2025-02-03T22:33:41.055Z"},"bugs":{"url":"https://github.com/help-me-mom/ng-mocks/issues"},"author":{"name":"Isaac Datlof","email":"ike18t@gmail.com","url":"https://github.com/ike18t"},"license":"MIT","homepage":"https://ng-mocks.sudo.eu","keywords":["angular","test","testing","mock","mocking","component","directive","pipe","provider","service","TestBed","how-to","frontend","front-end","jest","jasmine","enzyme","stub","dependency"],"repository":{"type":"git","url":"git+https://github.com/help-me-mom/ng-mocks.git"},"description":"An Angular testing library for creating mock services, components, directives, pipes and modules in unit tests. It provides shallow rendering, precise stubs to fake child dependencies. ng-mocks works with Angular 5 6 7 8 9 10 11 12 13 14 15 16 17 18, jasm","maintainers":[{"name":"bobbyg603","email":"bobbyg603@gmail.com"}],"readme":"[<img src=\"https://img.shields.io/gitter/room/help-me-mom/ng-mocks\" alt=\"chat on gitter\" width=\"90\" height=\"20\" />](https://gitter.im/ng-mocks/community)\n[<img src=\"https://img.shields.io/npm/v/ng-mocks\" alt=\"npm version\" width=\"88\" height=\"20\" />](https://www.npmjs.com/package/ng-mocks)\n[<img src=\"https://img.shields.io/circleci/build/github/help-me-mom/ng-mocks/master\" alt=\"build status\" width=\"88\" height=\"20\" />](https://app.circleci.com/pipelines/github/help-me-mom/ng-mocks?branch=master)\n[<img src=\"https://img.shields.io/coveralls/github/help-me-mom/ng-mocks/master\" alt=\"coverage status\" width=\"104\" height=\"20\" />](https://coveralls.io/github/help-me-mom/ng-mocks?branch=master)\n\n# Mock components, services and more out of annoying dependencies for simplification of Angular testing\n\n`ng-mocks` facilitates **Angular testing** and helps to:\n\n- **mock Components**, Directives, Pipes, Modules, Services and Tokens\n- reduce boilerplate in tests\n- access declarations via simple interface\n\nThe current version of the library **has been tested** and **can be used** with:\n\n| angular | ng-mocks | jasmine | jest | ivy | standalone | signals | defer |\n| ------: | :------: | :-----: | :--: | :-: | :--------: | :-----: | :---: |\n|      19 |  latest  |   yes   | yes  | yes |    yes     |   no    |  no   |\n|      18 |  latest  |   yes   | yes  | yes |    yes     |   no    |  no   |\n|      17 |  latest  |   yes   | yes  | yes |    yes     |   no    |  no   |\n|      16 |  latest  |   yes   | yes  | yes |    yes     |   no    |       |\n|      15 |  latest  |   yes   | yes  | yes |    yes     |         |       |\n|      14 |  latest  |   yes   | yes  | yes |    yes     |         |       |\n|      13 |  latest  |   yes   | yes  | yes |            |         |       |\n|      12 |  latest  |   yes   | yes  | yes |            |         |       |\n|      11 |  latest  |   yes   | yes  | yes |            |         |       |\n|      10 |  latest  |   yes   | yes  | yes |            |         |       |\n|       9 |  latest  |   yes   | yes  | yes |            |         |       |\n|       8 |  latest  |   yes   | yes  |     |            |         |       |\n|       7 |  latest  |   yes   | yes  |     |            |         |       |\n|       6 |  latest  |   yes   | yes  |     |            |         |       |\n|       5 |  latest  |   yes   | yes  |     |            |         |       |\n\n## Important links\n\n- **[Documentation with examples of Angular testing](https://ng-mocks.sudo.eu)**\n- [CHANGELOG](https://github.com/help-me-mom/ng-mocks/blob/master/CHANGELOG.md)\n- [GitHub repo](https://github.com/help-me-mom/ng-mocks)\n- [NPM package](https://www.npmjs.com/package/ng-mocks)\n\n* Live [example on CodeSandbox](https://codesandbox.io/p/sandbox/github/help-me-mom/ng-mocks-sandbox/tree/master/?file=/src/test.spec.ts)\n* Live [example on StackBlitz](https://stackblitz.com/github/help-me-mom/ng-mocks-sandbox?file=src/test.spec.ts)\n\n- [start a discussion on GitHub](https://github.com/help-me-mom/ng-mocks/discussions/new/choose)\n- **[ask a question on Stackoverflow](https://stackoverflow.com/questions/ask?tags=ng-mocks%20angular%20testing%20mocking)**\n- [report an issue on GitHub](https://github.com/help-me-mom/ng-mocks/issues)\n- [chat on gitter](https://gitter.im/ng-mocks/community)\n\n## Very short introduction\n\nGlobal configuration for mocks in `src/test.ts`.\nIn case of jest, `src/setup-jest.ts` / `src/test-setup.ts` should be used.\n\n```ts title=\"src/test.ts\"\n// All methods in mock declarations and providers\n// will be automatically spied on their creation.\n// https://ng-mocks.sudo.eu/extra/auto-spy\nngMocks.autoSpy('jasmine'); // or jest\n\n// ngMocks.defaultMock helps to customize mocks\n// globally. Therefore, we can avoid copy-pasting\n// among tests.\n// https://ng-mocks.sudo.eu/api/ngMocks/defaultMock\nngMocks.defaultMock(AuthService, () => ({\n  isLoggedIn$: EMPTY,\n  currentUser$: EMPTY,\n}));\n```\n\nAn example of a spec for a profile edit component.\n\n```ts title=\"src/profile.component.spec.ts\"\n// Let's imagine that there is a ProfileComponent\n// and it has 3 text fields: email, firstName,\n// lastName, and a user can edit them.\n// In the following test suite, we would like to\n// cover behavior of the component.\ndescribe('profile:builder', () => {\n  // Helps to reset customizations after each test.\n  // Alternatively, you can enable\n  // automatic resetting in test.ts.\n  MockInstance.scope();\n\n  // Let's configure TestBed via MockBuilder.\n  // The code below says to mock everything in\n  // ProfileModule except ProfileComponent and\n  // ReactiveFormsModule.\n  beforeEach(() => {\n    // The result of MockBuilder should be returned.\n    // https://ng-mocks.sudo.eu/api/MockBuilder\n    return MockBuilder(\n      ProfileComponent,\n      ProfileModule,\n    ).keep(ReactiveFormsModule);\n    // // or old fashion way\n    // return TestBed.configureTestingModule({\n    //   imports: [\n    //     MockModule(SharedModule), // mock\n    //     ReactiveFormsModule, // real\n    //   ],\n    //   declarations: [\n    //     ProfileComponent, // real\n    //     MockPipe(CurrencyPipe), // mock\n    //     MockDirective(HoverDirective), // mock\n    //   ],\n    //   providers: [\n    //     MockProvider(AuthService), // mock\n    //   ],\n    // }).compileComponents();\n  });\n\n  // A test to ensure that ProfileComponent\n  // can be created.\n  it('should be created', () => {\n    // MockRender is an advanced version of\n    // TestBed.createComponent.\n    // It respects all lifecycle hooks,\n    // onPush change detection, and creates a\n    // wrapper component with a template like\n    // <app-root ...allInputs></profile>\n    // and renders it.\n    // It also respects all lifecycle hooks.\n    // https://ng-mocks.sudo.eu/api/MockRender\n    const fixture = MockRender(ProfileComponent);\n\n    expect(\n      fixture.point.componentInstance,\n    ).toEqual(assertion.any(ProfileComponent));\n  });\n\n  // A test to ensure that the component listens\n  // on ctrl+s hotkey.\n  it('saves on ctrl+s hot key', () => {\n    // A fake profile.\n    const profile = {\n      email: 'test2@email.com',\n      firstName: 'testFirst2',\n      lastName: 'testLast2',\n    };\n\n    // A spy to track save calls.\n    // MockInstance helps to configure mock\n    // providers, declarations and modules\n    // before their initialization and usage.\n    // https://ng-mocks.sudo.eu/api/MockInstance\n    const spySave = MockInstance(\n      StorageService,\n      'save',\n      jasmine.createSpy(), // or jest.fn()\n    );\n\n    // Renders <profile [profile]=\"params.profile\">\n    // </profile>.\n    // https://ng-mocks.sudo.eu/api/MockRender\n    const { point } = MockRender(\n      ProfileComponent,\n      { profile }, // bindings\n    );\n\n    // Let's change the value of the form control\n    // for email addresses with a random value.\n    // ngMocks.change finds a related control\n    // value accessor and updates it properly.\n    // https://ng-mocks.sudo.eu/api/ngMocks/change\n    ngMocks.change(\n      '[name=email]', // css selector\n      'test3@em.ail', // an email address\n    );\n\n    // Let's ensure that nothing has been called.\n    expect(spySave).not.toHaveBeenCalled();\n\n    // Let's assume that there is a host listener\n    // for a keyboard combination of ctrl+s,\n    // and we want to trigger it.\n    // ngMocks.trigger helps to emit events via\n    // simple interface.\n    // https://ng-mocks.sudo.eu/api/ngMocks/trigger\n    ngMocks.trigger(point, 'keyup.control.s');\n\n    // The spy should be called with the user\n    // and the random email address.\n    expect(spySave).toHaveBeenCalledWith({\n      email: 'test3@em.ail',\n      firstName: profile.firstName,\n      lastName: profile.lastName,\n    });\n  });\n});\n```\n\nProfit.\n\n## Extra\n\nIf you like `ng-mocks`, please support it:\n\n- [with a star on GitHub](https://github.com/help-me-mom/ng-mocks)\n- [with a tweet](https://twitter.com/intent/tweet?text=Check%20ng-mocks%20package%20%23angular%20%23testing%20%23mocking&url=https%3A%2F%2Fgithub.com%2Fhelp-me-mom%2Fng-mocks)\n\nThank you!\n\nP.S. Feel free to [contact us](https://ng-mocks.sudo.eu/need-help) if you need help.\n","readmeFilename":"README.md"}