Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
390 views
in Technique[技术] by (71.8m points)

angularjs - scope not accessible in Unit test with Jasmine

Here is my unit test

    describe('Filter', function () {
    beforeEach(function () {
        template = `<div class="workspace"><filter api-object="apiObject"></filter></div>`;
    });
    describe('default', function() {
        it('attributes', function () {
            scope.savedFilters = savedFilters;
            scope.availableFiltersMap = {
                name: true,
                description: true
            };
            spyOn(ViewSelect, "getFilter").and.returnValue(scope.savedFilters);
            element = test.compileElement(template, scope);
            scope.$emit(scope.apiObject.id, true);
            httpBackend.flush();
            expect(scope.filters.length).toBe(2);
        });
    });
});

Here my intention to test filters length but it's not available in direct scope it's available in $$childhead. When I use scope.$$childhead.filters it's throwing error Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL. Please help me why it is not accessible directly on the scope? any help would be appreciated Please.

question from:https://stackoverflow.com/questions/66056930/scope-not-accessible-in-unit-test-with-jasmine

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...