On add to a lineItem doesn't have a tax adjuster associated with it (The tax is on the whole order though).
I tracked it down to https://github.com/craftcms/commerce/blob/develop/src/adjusters/Tax.php#L163
When it hits this part on first add $item->id returns null. If you subsequently update the cart the tax adjuster starts working.
Here is a little gif example, it starts having just added the product to the cart and shows 0 for item.getAdjustmentsTotalByType( 'tax', true ): http://x.n43.me/2B1n0z2E021T/Screen%20Recording%202018-07-18%20at%2005.54%20pm.gif
(gif isn't frozen in the middle just my local vagrant box decided to be super slow on that submit)
item.getAdjustmentsTotalByType( 'tax', true ) in cart.lineItems loop and it displays 0Confirmed. Will Investigate a solution.
I think this is related but I just ran into this wondering why my line items weren't showing up in a cart.
Here's a common use case...
After adding a new item to the cart where the customer has already put a coupon code in, Commerce will set the adjuster to be a cart adjustment and not an item adjustment.
This is a problem because there's not really a good way to show "You saved X" on the individual line item if it's a cart adjustment. The total discount coupon is right but it will look WRONG to a customer.
Updating the cart again immediately fixes the problem.
Here's a debug cart to illustrate...
I just added a 10 lb bag (of flour) to the cart:

Updating the cart fixes the problem:

Sounds like there just needs to be some internal update/cleanup happening.
I鈥檝e just run into this as well ... it seems like if the line items haven鈥檛 yet got an ID they need saving first before the adjustments run. Or the order needs recalculating at some point.
Correct, the issue is that the new line item's ID does not get created until the order is saved which happens after the order recalculates it's adjustments. Will have a solution out soon.
Thanks @lukeholder - yeah I tried to unpick where to fix this, listening to after the order or line item is saved seem like a good idea but I couldn鈥檛 get that to work ha. Good luck!
OK, this should be now fixed on the develop branch.
Adjusters now need to set the line item affected on the adjustment model.
An adjustment model always belongs to an order, but can optionally belong to a line item. When creating the adjustment model, if the adjustment is for a particular line item, you will need to set it on the adjustment model like this:
$adjustment->setLineItem($lineItem)
This ensures that even if the line item is new and has no ID yet, the adjustment can reference the correct line item.
Most helpful comment
OK, this should be now fixed on the develop branch.
Adjusters now need to set the line item affected on the adjustment model.
An adjustment model always belongs to an order, but can optionally belong to a line item. When creating the adjustment model, if the adjustment is for a particular line item, you will need to set it on the adjustment model like this:
$adjustment->setLineItem($lineItem)This ensures that even if the line item is new and has no ID yet, the adjustment can reference the correct line item.