diff --git a/commands.js b/commands.js
index 8945cb95d78cb24d8d96704dbadb1d52327a50de..13f562923debae5f6d1c5c4de616ae6fe39e02c6 100644
--- a/commands.js
+++ b/commands.js
@@ -13,6 +13,7 @@ Cypress.Commands.add('login', (options) => {
 })
 
 Cypress.Commands.add('createAndLogin', (username, role) => {
+    cy.rememberLatestTaxonomyTerm();
     let password = 'random-password-' + Cypress._.random(0, 1e6);
     cy.drush('user:create ' + username + ' --password=' + password);
     cy.drush('user:role:add ' + role + ' ' + username);
@@ -25,6 +26,7 @@ Cypress.Commands.add('createAndLogin', (username, role) => {
 
 Cypress.Commands.add('deleteLogin', (username) => {
     cy.drush('user:cancel --delete-content ' + username);
+    cy.deleteTestTaxonomyTerms();
 })
 
 Cypress.Commands.add('checkSessionCookie', () => {
@@ -43,3 +45,24 @@ Cypress.Commands.add('checkSessionCookie', () => {
 Cypress.Commands.add('drush', (command) => {
     cy.exec('docker exec $PHP_CONTAINER drush -y ' + command)
 })
+
+let maxTid = -1;
+
+Cypress.Commands.add('rememberLatestTaxonomyTerm', () => {
+    cy.drush('sql:query "select max(tid) from taxonomy_term_data"').then((result) => {
+        cy.log(result);
+        maxTid = result.stdout;
+    });
+})
+
+Cypress.Commands.add('deleteTestTaxonomyTerms', () => {
+    if (maxTid < 1) {
+        return;
+    }
+    cy.drush('sql:query "select tid from taxonomy_term_data where tid>' + maxTid + '"').then((result) => {
+        let tids = result.stdout.split("\n").join(',');
+        if (tids) {
+            cy.drush('edel taxonomy_term ' + tids);
+        }
+    });
+})