Replace Saucelabs with Playwright
Also reorganized npm scripts.
This commit is contained in:
committed by
Jay Linski
parent
ef0fc290b9
commit
9ed9418488
@@ -4,7 +4,6 @@
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
npm-debug.log
|
||||
sauce_connect.log*
|
||||
.idea
|
||||
yarn-error.log
|
||||
node_modules
|
||||
|
||||
@@ -9,23 +9,22 @@ on:
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Lint (ESlint)
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
|
||||
- name: Lint (Prettier)
|
||||
run: npm run check-format
|
||||
|
||||
- name: Lint (TypeScript)
|
||||
run: npm run dtslint
|
||||
|
||||
test:
|
||||
name: Test
|
||||
runs-on: ${{ matrix.operating-system }}
|
||||
@@ -52,3 +51,31 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: npm run test
|
||||
|
||||
browser:
|
||||
name: Browser Tests
|
||||
runs-on: 'ubuntu-latest'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Install Playwright
|
||||
run: |
|
||||
npx playwright install-deps
|
||||
npx playwright install
|
||||
|
||||
- name: Build
|
||||
run: npx grunt prepare
|
||||
|
||||
- name: Test
|
||||
run: npm run test:browser
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
npm-debug.log
|
||||
sauce_connect.log*
|
||||
.idea
|
||||
/yarn-error.log
|
||||
/yarn.lock
|
||||
|
||||
+15
-74
@@ -165,48 +165,6 @@ module.exports = function(grunt) {
|
||||
}
|
||||
}
|
||||
},
|
||||
'saucelabs-mocha': {
|
||||
all: {
|
||||
options: {
|
||||
build: process.env.TRAVIS_JOB_ID,
|
||||
urls: [
|
||||
'http://localhost:9999/spec/?headless=true',
|
||||
'http://localhost:9999/spec/amd.html?headless=true'
|
||||
],
|
||||
detailedError: true,
|
||||
concurrency: 4,
|
||||
browsers: [
|
||||
{ browserName: 'chrome' },
|
||||
{ browserName: 'firefox', platform: 'Linux' }
|
||||
// {browserName: 'safari', version: 9, platform: 'OS X 10.11'},
|
||||
// {browserName: 'safari', version: 8, platform: 'OS X 10.10'},
|
||||
// {
|
||||
// browserName: 'internet explorer',
|
||||
// version: 11,
|
||||
// platform: 'Windows 8.1'
|
||||
// },
|
||||
// {
|
||||
// browserName: 'internet explorer',
|
||||
// version: 10,
|
||||
// platform: 'Windows 8'
|
||||
// }
|
||||
]
|
||||
}
|
||||
},
|
||||
sanity: {
|
||||
options: {
|
||||
build: process.env.TRAVIS_JOB_ID,
|
||||
urls: [
|
||||
'http://localhost:9999/spec/umd.html?headless=true',
|
||||
'http://localhost:9999/spec/amd-runtime.html?headless=true',
|
||||
'http://localhost:9999/spec/umd-runtime.html?headless=true'
|
||||
],
|
||||
detailedError: true,
|
||||
concurrency: 2,
|
||||
browsers: [{ browserName: 'chrome' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
bgShell: {
|
||||
integrationTests: {
|
||||
@@ -238,22 +196,14 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-babel');
|
||||
grunt.loadNpmTasks('grunt-bg-shell');
|
||||
grunt.loadNpmTasks('@knappi/grunt-saucelabs');
|
||||
grunt.loadNpmTasks('grunt-webpack');
|
||||
|
||||
grunt.task.loadTasks('tasks');
|
||||
|
||||
this.registerTask(
|
||||
'build',
|
||||
'Builds a distributable version of the current project',
|
||||
['parser', 'node', 'globals']
|
||||
);
|
||||
|
||||
this.registerTask('node', ['babel:cjs']);
|
||||
this.registerTask('globals', ['webpack']);
|
||||
|
||||
this.registerTask('release', 'Build final packages', [
|
||||
'amd',
|
||||
grunt.registerTask('node', ['babel:cjs']);
|
||||
grunt.registerTask('amd', ['babel:amd', 'requirejs']);
|
||||
grunt.registerTask('globals', ['webpack']);
|
||||
grunt.registerTask('release', 'Build final packages', [
|
||||
'uglify',
|
||||
'test:min',
|
||||
'copy:dist',
|
||||
@@ -261,36 +211,27 @@ module.exports = function(grunt) {
|
||||
'copy:cdnjs'
|
||||
]);
|
||||
|
||||
this.registerTask('amd', ['babel:amd', 'requirejs']);
|
||||
|
||||
this.registerTask('test', ['test:bin', 'test:cov']);
|
||||
|
||||
grunt.registerTask('bench', ['metrics']);
|
||||
|
||||
if (process.env.SAUCE_ACCESS_KEY) {
|
||||
grunt.registerTask('sauce', ['concat:tests', 'connect', 'saucelabs-mocha']);
|
||||
} else {
|
||||
grunt.registerTask('sauce', []);
|
||||
}
|
||||
|
||||
// Requires secret properties (saucelabs-credentials etc.) from .travis.yaml
|
||||
// Requires secret properties from .travis.yaml
|
||||
grunt.registerTask('extensive-tests-and-publish-to-aws', [
|
||||
'default',
|
||||
'bgShell:integrationTests',
|
||||
'sauce',
|
||||
'metrics',
|
||||
'publish-to-aws'
|
||||
]);
|
||||
grunt.registerTask('on-file-change', [
|
||||
'build',
|
||||
'amd',
|
||||
'concat:tests',
|
||||
'test'
|
||||
]);
|
||||
|
||||
grunt.registerTask('on-file-change', ['build', 'concat:tests', 'test']);
|
||||
|
||||
// === Primary tasks ===
|
||||
grunt.registerTask('dev', ['clean', 'connect', 'watch']);
|
||||
grunt.registerTask('default', ['clean', 'build', 'test', 'release']);
|
||||
grunt.registerTask('test', ['test:bin', 'test:cov']);
|
||||
grunt.registerTask('bench', ['metrics']);
|
||||
grunt.registerTask('prepare', ['build', 'concat:tests']);
|
||||
grunt.registerTask(
|
||||
'build',
|
||||
'Builds a distributable version of the current project',
|
||||
['parser', 'node', 'amd', 'globals']
|
||||
);
|
||||
grunt.registerTask('integration-tests', [
|
||||
'default',
|
||||
'bgShell:integrationTests'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
[](https://github.com/handlebars-lang/handlebars.js/actions)
|
||||
[](https://saucelabs.com/u/handlebars)
|
||||
[](https://www.jsdelivr.com/package/npm/handlebars)
|
||||
[](https://bundlephobia.com/package/handlebars)
|
||||
[](https://packagephobia.com/result?p=handlebars)
|
||||
@@ -91,8 +90,6 @@ Handlebars has been designed to work in any ECMAScript 3 environment. This inclu
|
||||
Older versions and other runtimes are likely to work but have not been formally
|
||||
tested. The compiler requires `JSON.stringify` to be implemented natively or via a polyfill. If using the precompiler this is not necessary.
|
||||
|
||||
[](https://saucelabs.com/u/handlebars)
|
||||
|
||||
Performance
|
||||
-----------
|
||||
|
||||
|
||||
Generated
+3258
-343
File diff suppressed because it is too large
Load Diff
+13
-8
@@ -30,7 +30,7 @@
|
||||
"uglify-js": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@knappi/grunt-saucelabs": "^9.0.2",
|
||||
"@playwright/test": "^1.17.1",
|
||||
"aws-sdk": "^2.1.49",
|
||||
"babel-loader": "^5.0.0",
|
||||
"babel-runtime": "^5.1.10",
|
||||
@@ -84,15 +84,20 @@
|
||||
"handlebars": "bin/handlebars"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "grunt build",
|
||||
"format": "prettier --write '**/*.js' && eslint --fix .",
|
||||
"check-format": "prettier --check '**/*.js'",
|
||||
"lint": "eslint --max-warnings 0 .",
|
||||
"dtslint": "dtslint types",
|
||||
"test": "grunt",
|
||||
"extensive-tests-and-publish-to-aws": "npx mocha tasks/task-tests/ && grunt --stack extensive-tests-and-publish-to-aws",
|
||||
"integration-test": "grunt integration-tests",
|
||||
"lint": "npm run lint:eslint && npm run lint:prettier && npm run lint:types",
|
||||
"lint:eslint": "eslint --max-warnings 0 .",
|
||||
"lint:prettier": "prettier --check '**/*.js'",
|
||||
"lint:types": "dtslint types",
|
||||
"test": "npm run test:mocha",
|
||||
"test:mocha": "grunt build && grunt test",
|
||||
"test:browser": "playwright test --config tests/browser/playwright.config.js tests/browser/spec.js",
|
||||
"test:integration": "grunt integration-tests",
|
||||
"test:serve": "node ./tests/server.js",
|
||||
"extensive-tests-and-publish-to-aws": "npx mocha tasks/tests/ && grunt --stack extensive-tests-and-publish-to-aws",
|
||||
"--- combined tasks ---": "",
|
||||
"check-before-pull-request": "concurrently --kill-others-on-fail npm:lint npm:dtslint npm:check-format npm:test"
|
||||
"check-before-pull-request": "concurrently --kill-others-on-fail npm:lint npm:test"
|
||||
},
|
||||
"jspm": {
|
||||
"main": "handlebars",
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
}
|
||||
var runner = mocha.run();
|
||||
|
||||
//Reporting for saucelabs
|
||||
// Reporting to test-runner
|
||||
var failedTests = [];
|
||||
runner.on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@
|
||||
}
|
||||
var runner = mocha.run();
|
||||
|
||||
//Reporting for saucelabs
|
||||
// Reporting to test-runner
|
||||
var failedTests = [];
|
||||
runner.on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@
|
||||
}
|
||||
var runner = mocha.run();
|
||||
|
||||
//Reporting for saucelabs
|
||||
// Reporting to test-runner
|
||||
var failedTests = [];
|
||||
runner.on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
}
|
||||
var runner = mocha.run();
|
||||
|
||||
//Reporting for saucelabs
|
||||
// Reporting to test-runner
|
||||
var failedTests = [];
|
||||
runner.on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@
|
||||
}
|
||||
var runner = mocha.run();
|
||||
|
||||
//Reporting for saucelabs
|
||||
// Reporting to test-runner
|
||||
var failedTests = [];
|
||||
runner.on('end', function(){
|
||||
window.mochaResults = runner.stats;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['eslint:recommended', 'prettier'],
|
||||
env: {
|
||||
node: true
|
||||
},
|
||||
parserOptions: {
|
||||
ecmaVersion: 6
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
# Browser Tests with Playwright
|
||||
|
||||
These tests execute Mocha tests from the `spec`-folder in multiple browsers.
|
||||
|
||||
## Using Docker
|
||||
|
||||
Execute the following commands in the project root:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npx grunt prepare
|
||||
docker pull mcr.microsoft.com/playwright:focal
|
||||
docker run -it --rm --volume $(pwd):/srv/app --workdir /srv/app --ipc=host mcr.microsoft.com/playwright:focal npm run test:browser
|
||||
```
|
||||
@@ -0,0 +1,27 @@
|
||||
const { devices } = require('@playwright/test');
|
||||
|
||||
/** @type {import('@playwright/test').PlaywrightTestConfig} */
|
||||
const config = {
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: { ...devices['Desktop Chrome'] }
|
||||
},
|
||||
{
|
||||
name: 'firefox',
|
||||
use: { ...devices['Desktop Firefox'] }
|
||||
},
|
||||
{
|
||||
name: 'webkit',
|
||||
use: { ...devices['Desktop Safari'] }
|
||||
}
|
||||
],
|
||||
reporter: 'list',
|
||||
webServer: {
|
||||
command: 'npm run test:serve',
|
||||
port: 3000,
|
||||
reuseExistingServer: false
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
@@ -0,0 +1,33 @@
|
||||
const { test, expect } = require('@playwright/test');
|
||||
|
||||
async function waitForMochaAndAssertResult(page) {
|
||||
await page.waitForFunction(() => window.mochaResults); // eslint-disable-line no-undef
|
||||
const mochaResults = await page.evaluate('window.mochaResults');
|
||||
|
||||
expect(mochaResults.failures).toBe(0);
|
||||
}
|
||||
|
||||
test('Spec handlebars.js', async ({ page, baseURL }) => {
|
||||
await page.goto(`${baseURL}/spec/?headless=true`);
|
||||
await waitForMochaAndAssertResult(page);
|
||||
});
|
||||
|
||||
test('Spec handlebars.amd.js (AMD)', async ({ page, baseURL }) => {
|
||||
await page.goto(`${baseURL}/spec/amd.html?headless=true`);
|
||||
await waitForMochaAndAssertResult(page);
|
||||
});
|
||||
|
||||
test('Spec handlebars.runtime.amd.js (AMD)', async ({ page, baseURL }) => {
|
||||
await page.goto(`${baseURL}/spec/amd-runtime.html?headless=true`);
|
||||
await waitForMochaAndAssertResult(page);
|
||||
});
|
||||
|
||||
test('Spec handlebars.js (UMD)', async ({ page, baseURL }) => {
|
||||
await page.goto(`${baseURL}/spec/umd.html?headless=true`);
|
||||
await waitForMochaAndAssertResult(page);
|
||||
});
|
||||
|
||||
test('Spec handlebars.runtime.js (UMD)', async ({ page, baseURL }) => {
|
||||
await page.goto(`${baseURL}/spec/umd-runtime.html?headless=true`);
|
||||
await waitForMochaAndAssertResult(page);
|
||||
});
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
const fs = require('fs');
|
||||
const http = require('http');
|
||||
const path = require('path');
|
||||
|
||||
const mimeTypes = {
|
||||
css: 'text/css',
|
||||
html: 'text/html',
|
||||
js: 'text/javascript',
|
||||
json: 'application/json'
|
||||
};
|
||||
|
||||
// Serve static files for spec tests
|
||||
http
|
||||
.createServer(function(req, res) {
|
||||
const url = new URL(req.url, `http://${req.headers.host}`);
|
||||
let filePath = `${path.resolve(__dirname, '..')}${url.pathname}`;
|
||||
|
||||
if (fs.existsSync(filePath) && fs.statSync(filePath).isDirectory()) {
|
||||
filePath += filePath.endsWith('/') ? '' : '/';
|
||||
filePath += 'index.html';
|
||||
}
|
||||
|
||||
fs.readFile(filePath, function(err, data) {
|
||||
if (err) {
|
||||
res.writeHead(404);
|
||||
res.end(JSON.stringify(err));
|
||||
return;
|
||||
}
|
||||
|
||||
let mimeType = mimeTypes[filePath.split('.').pop()] || 'text/plain';
|
||||
|
||||
res.writeHead(200, { 'Content-Type': mimeType });
|
||||
res.end(data);
|
||||
});
|
||||
})
|
||||
.listen(3000);
|
||||
Reference in New Issue
Block a user