Kaynağa Gözat

UI Tests: Implement filtering

Danilo Bargen 6 yıl önce
ebeveyn
işleme
abbaf479aa
3 değiştirilmiş dosya ile 19 ekleme ve 9 silme
  1. 4 0
      README.md
  2. 1 4
      tests/ui/run.sh
  3. 14 5
      tests/ui/run.ts

+ 4 - 0
README.md

@@ -78,6 +78,10 @@ For example:
     npm run test:ui firefox
     npm run test:ui chrome
 
+You can also filter the test cases:
+
+    npm run test:ui firefox emoji
+
 To run linting checks:
 
     npm run lint

+ 1 - 4
tests/ui/run.sh

@@ -6,12 +6,9 @@ fi
 
 export PATH=$PATH:"$(pwd)/node_modules/.bin/"
 
-browser=$1
-shift
-
 concurrently \
     --kill-others \
     -s first \
     --names \"server,test\" \
     "npm run testserver" \
-    "ts-node --skip-project -O '{\"target\": \"ES2015\"}' tests/ui/run.ts $browser"
+    "ts-node --skip-project -O '{\"target\": \"ES2015\"}' tests/ui/run.ts $*"

+ 14 - 5
tests/ui/run.ts

@@ -18,6 +18,7 @@ import { extractText } from '../../src/helpers';
 
 // Script arguments
 const browser = process.argv[2];
+const filterQuery = process.argv[3];
 
 // Type aliases
 type Testfunc = (driver: WebDriver) => void;
@@ -114,13 +115,21 @@ const TEST_URL = 'http://localhost:7777/tests/ui/compose_area.html';
     let i = 0;
     let success = 0;
     let failed = 0;
+    let skipped = 0;
     console.info('\n====== THREEMA WEB UI TESTS ======\n');
+    if (filterQuery !== undefined) {
+        console.info(`Filter query: "${filterQuery}"\n`);
+    }
     try {
         for (const [name, testfunc] of TESTS) {
-            console.info(TermColor.blue(`» ${i + 1}: Running test: ${name}`));
-            await driver.get(TEST_URL);
-            await testfunc(driver);
-            success++;
+            if (filterQuery === undefined || name.toLowerCase().indexOf(filterQuery.toLowerCase()) !== -1) {
+                console.info(TermColor.blue(`» ${i + 1}: Running test: ${name}`));
+                await driver.get(TEST_URL);
+                await testfunc(driver);
+                success++;
+            } else {
+                skipped++;
+            }
             i++;
         }
     } catch (e) {
@@ -131,6 +140,6 @@ const TEST_URL = 'http://localhost:7777/tests/ui/compose_area.html';
         await driver.quit();
     }
     const colorFunc = failed > 0 ? TermColor.red : TermColor.green;
-    console.info(colorFunc(`\nSummary: ${i} tests run, ${success} succeeded, ${failed} failed`));
+    console.info(colorFunc(`\nSummary: ${i} tests run, ${success} succeeded, ${failed} failed, ${skipped} skipped`));
     process.exit(failed > 0 ? 1 : 0);
 })();