bahmutov / bahmutov/cypress-angularjs-unit-test

Cannot access the mounted element from document

Open
#82 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Unable to query the mounted element from `document` while it is accessible from `$rootElement`.

### How to reproduce?

```javascript
import angular from 'angular';
import { mount } from 'cypress-angularjs-unit-test';

it('should find the element from document', (done) => {
const module = angular.module('app', []);

module.run(($timeout, $rootElement) => {
console.log($rootElement[0].querySelector('.target')); //


console.log(document.querySelector('.target')); // null

$timeout(() => {
console.log($rootElement[0].querySelector('.target')); //


console.log(document.querySelector('.target')); // null

done();
});
});

mount('

', ['app']);

console.log(document.querySelector('.target')); // null
});
```

### Expected behavior

Should able to access the mounted element from `document`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the supplied Cypress test and tracing the mount entry point, comparing the mounted element’s $rootElement location with document.querySelector('.target'). Check the AngularJS module.run timing and the document state before and after mount. Done means the mounted element is discoverable through document.querySelector in both shown checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
angularjs, cypress, javascript
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.