As @ValeriySiestov mentioned, div is a block element, and li is a block element as well.
One way to fix your problem is to change the structure of the html you are appending, so it is a span element within the li element.
Note that list elements (i.e. uls or ols) can only have lis as their children, but lis can have anything as their children. Reference: Can I use a div inside a list item?
Assuming you have an unordered list with id #list, you can append a new list item to it like so:
var new_task = "walk the dog"
var li_string = `<li>${new_task}: <span>Test</span></li>`
$('#list').append(li_string);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul id="list">
<li>make bed</li>
<li>brush teeth</li>
</ul>
Note the variable new_task is being interpolated within the string of html being appended to the list using template literals.
Template literals syntax:
string text ${expression} string text
liareulandol. You are creating invalid HTML. You cannot have anlias a child of adiv.lias a child of adiv, but you can have adivas a child of anli.<div><li>${new_task}</li> <div>Test</div></div>, you could append something like<li>${new_task} <span>Test</span></li>. In this case, aspanmay be better than adivfor your purposes, since aspanis an inline element, whereas adivis a block element.