How to verify if a transaction is signed correctly? Given an arbitrary signed raw transaction, how can we easily verify if all inputs are correctly signed (assuming all inputs are existent/unspent and the fee is higher than zero)? Bitcoin core's RPC command testmempoolaccept will check if all inputs are available to be spent in the mempool/blockchain so it's impossible to test transactions that have parents not yet broadcasted.
I am aware that for this kind of check, the scriptPubKeys of all inputs needs to be known and therefore only the signed raw transaction by itself is not enough for this kind of check. Still, the scriptPubKeys could be passed to the transaction instance or verify method. I was looking for some nice way to do this in python/javascript but was surprised how difficult this task is:

Peter Todd's python-bitcoinlib requires each input to be validated manually with some flags indicating the type of ScriptPubKey.
1200wd bitcoinlib, has a transaction.verify() method but it seems to only verify the basic transaction types: coinbase, P2PKH, P2SH(P2PKH), P2SH(multisig), ...
BitcoinJS has a method for this, psbt.validateSignaturesOfAllInputs() but converting a raw transaction to PSBT is not possible/easy.
Bitcore's transaction.verify() does mostly some basic sanity checks and doesn't verify the signatures.
BitcoinJ's transaction.verify() does also basic verification and the script execution, as python-bitcoinlib, has also to be done manually with verification flags.
Pubkey script alone is not enough to verify a transaction, you'll need:

Pubkey script, to evaluate the scripts
Amount, in order to check if the sum of inputs is bigger than or equal to sum of outputs
Index (in TxOut list) and tx hash of the transaction being spent
Block height so that you can set the consensus rules

After gathering all the above (should be found in the node's UTXO database) you can start evaluating if the provided script is valid which isn't limited to signature verification but running/evaluating the script that includes checking correctness of the script, OP codes, OP count, script size,...
A lot of the verification can be found in validation.cpp file.
This is also how I do it in Bitcoin.Net library.