Mailer Previews and deprecated warning and DebugKit

I’m trying to implement Mailer as suggested in the book creating-reusable-emails and came across a dichotomy between unit testing and Mailer Previews in debugKit.

Either I have a deprecation warning

Deprecated Error: Email::setTemplate() is deprecated. Use $email->viewBuilder()->setTemplate() instead. - /Users/nicolas/Sites/phd_school_apply/vendor/cakephp/cakephp/src/Mailer/Mailer.php, line: 258

and my preview in debugKit is ok

If I correct the warning, the unit test passes but then I get the following message in debugKit:

Argument 1 passed to DebugKit\Mailer\PreviewResult::__construct() must be an instance of Cake\Mailer\Mailer, instance of Cake\View\ViewBuilder given, called in /Users/nicolas/Sites/phd_school_apply/vendor/cakephp/debug_kit/src/Controller/MailPreviewController.php on line 263

and cannot preview my message. Any suggestion about this behaviour?

My Mailer class

namespace App\Mailer;

use Cake\Core\Configure;
use Cake\Mailer\Mailer;

class UserMailer extends Mailer{

    public function recommandationRequest($to, $reference, $profile){
        return $this
            ->setSubject('Letter of recommendation requested by ' . $profile['firstname'] . ' ' . $profile['lastname'])
            ->set(['reference' => $reference, 'profile' => $profile])
    // or ->viewBuilder()->setTemplate('recommandation_request');