Found input variables with inconsistent numbers of samples: [30, 24]
I had the same problem, here is how I sloved it:
testX is a tf.data.Dataset, I guess.
In that case try the following:
# make the prdictions from your test set:
testPredictRaw = self.model.predict(testX)  
testPredict = np.argmax(testPredictRaw, axis=1)

# Then, take all the y values from the prefetch dataset (thus changing the shape):
trueClasses = tf.concat([y for x, y in testY], axis=0)

# Calculate the confusion matrix using sklearn.metrics
cm = metrics.confusion_matrix(trueClasses, testPredict)

I used these answered questions to make it work for my case:

https://stackoverflow.com/questions/53620259/sci-kit-learn-confusion-matrix-found-input-variables-with-inconsistent-numbers
https://stackoverflow.com/questions/64622210/how-to-plot-confusion-matrix-for-prefetched-dataset-in-tensorflow