-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
55b8b5f
commit 6662120
Showing
2 changed files
with
39 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,29 @@ | ||
// *********************************************************** | ||
// This example support/component.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands'; | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') | ||
|
||
import { mount } from 'cypress/angular'; | ||
|
||
// Augment the Cypress namespace to include type definitions for | ||
// your custom command. | ||
// Alternatively, can be defined in cypress/support/component.d.ts | ||
// with a <reference path="./component" /> at the top of your spec. | ||
import { Type } from '@angular/core' | ||
import { NgSelectModule } from '@ng-select/ng-select'; | ||
import { mount, MountConfig } from 'cypress/angular' | ||
declare global { | ||
namespace Cypress { | ||
interface Chainable { | ||
mount: typeof mount; | ||
mount: typeof customMount | ||
} | ||
} | ||
} | ||
|
||
Cypress.Commands.add('mount', mount); | ||
|
||
// Example use: | ||
// cy.mount(MyComponent) | ||
// Source : https://docs.cypress.io/guides/component-testing/angular/examples#Default-Declarations-Providers-or-Imports | ||
const declarations = [] | ||
const imports = [NgSelectModule] | ||
const providers = [] | ||
|
||
function customMount<T>(component: string | Type<T>, config?: MountConfig<T>) { | ||
if (!config) { | ||
config = { declarations, imports, providers } | ||
} else { | ||
config.declarations = [...(config?.declarations || []), ...declarations] | ||
config.imports = [...(config?.imports || []), ...imports] | ||
config.providers = [...(config?.providers || []), ...providers] | ||
} | ||
return mount<T>(component, config) | ||
} | ||
|
||
Cypress.Commands.add('mount', customMount) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters