How do I add svg files via MatIconRegistry in unit tests?

can just do: import { MatIcon } from ‘@angular/material/icon’; import { MatIconTestingModule } from ‘@angular/material/icon/testing’; describe(‘MyComponent’, () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [MyComponent, MatIcon], imports: [MatIconTestingModule], }).compileComponents(); })); … }); This will generate a test icon rendering without the HTTP request. NOTE: Newer versions of Angular, e.g., >16, may produce an error unless … Read more

pytest fixtures in a separate directory

Please add the following in your conftest.py import pytest pytest_plugins = [ “fixtures.conftest”, “fixtures.fixture_cifs”, “fixtures.fixture_ftp”, “fixtures.fixture_service” ] This ensures that all fixtures declared under fixtures/ will be found by pytest As a note that the respective directories referred to in fixtures.conftest” need to have __init__.py files for the plugins to be loaded by pytest A … Read more

Accessing Angular inside Protractor Test

There is a function called evaluate(). Find an element in the dom and then run the expression. For example. If you want to count the number of todos in the http://angularjs.org/ website (under Add Some Control), do this: Open the element explorer in protractor ./node_modules/protractor/bin/elementexplorer.js browser.get(‘http://angularjs.org/’) element(by.model(‘todoText’)).evaluate(‘todos.length’). then(function(count) { console.log(count) }); It should give you … Read more

Protractor “by.css()” vs “$()” Dollar Sign vs “$$()” ‘Bling Bling’

$ and $$ are just convenient shortcuts. $(“selector”) is an alternative for element(by.css(“selector”)). $$(“selector”) is an alternative for element.all(by.css(“selector”)). FYI, quote from the source code: ElementFinder.prototype.$ = function(selector) { return this.element(webdriver.By.css(selector)); }; ElementArrayFinder.prototype.$$ = function(selector) { return this.all(webdriver.By.css(selector)); }; And the actual commit that initially made it happen.

How to stop all tests from inside a test or setUp using unittest?

In case you are interested, here is a simple example how you could make a decision yourself about exiting a test suite cleanly with py.test: # content of test_module.py import pytest counter = 0 def setup_function(func): global counter counter += 1 if counter >=3: pytest.exit(“decided to stop the test run”) def test_one(): pass def test_two(): … Read more

Display python unittest results in nice, tabular form [closed]

This is not exactly what you are asking, but there are several options for having a readable test output there: HTMLTestRunner generates easy to use HTML test reports in a tabular form. Here’s a sample report. nose-html-output plugin for nose test runner unittest-xml-reporting – PyUnit-based test runner with JUnit like XML reporting nose with –with-xunit … Read more