karma-runner / karma-runner/karma

Doubling <script> elements in the <body> client context.html file that are set to included:true when autoWatch:true

Open
#2,728 0 comments 0 reactions 0 assignees View on GitHub
PR exists
Dominant language
JavaScript
Stars
12k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### Actual behaviour

When I set my `karma.conf.js` with these options:
```javasctipt
client{
runInParent: true,
useIframe:false
}
```
on every autoWatch reload, all files that are specified in `karma.conf.js` `files: [ ... ]` array and are set to `included:true` are appended to the `` extra time, so after 5 changes in my watched file, I have 5 `` elements in my body repeated.

It does not happen if I use those settings:
```javascript
client{
runInParent: false,
useIframe:false
}
//or
client{
runInParent: true, //or false
useIframe:true
}
```

### Expected behaviour
For me, it should append the same `script` tags of the same `src` attribute only once.

### Environment Details

- Karma version (output of `karma --version`): **1.7.0**
- Relevant part of your `karma.config.js` file

### Steps to reproduce the behaviour

1. Check out whether the document.body of `context.html` file contains the scripts of the same src attribute, that the scripts that are about to be loaded - if so - remove those script elements from body and append them again to re-run their scripts.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reload behavior with the shown karma.conf.js client settings and inspect the script-loading logic in context.html. Verify that repeated autoWatch reloads do not leave duplicate script elements in document.body while still re-running the scripts.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.