Merge pull request #24872 from nextcloud/tests/jsunit-chromium

Run jsunit with chromium/puppeteer
This commit is contained in:
Roeland Jago Douma 2020-12-29 10:59:49 +01:00 committed by GitHub
commit 50d5229c95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 1076 additions and 2274 deletions

View File

@ -1,27 +1,4 @@
kind: pipeline kind: pipeline
name: jsunit
steps:
- name: jsunit
image: nextcloudci/jsunit:jsunit-5
environment:
CODECOV_TOKEN:
from_secret: CODECOV_TOKEN
commands:
- ./autotest-js.sh
- curl -o codecov.sh https://codecov.io/bash
- bash codecov.sh -C $DRONE_COMMIT
trigger:
branch:
- master
- stable*
event:
- pull_request
- push
---
kind: pipeline
name: checkers name: checkers
steps: steps:

View File

@ -49,6 +49,17 @@ jobs:
- name: Test - name: Test
run: npm run test run: npm run test
jsunit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use node ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Test
run: ./autotest-js.sh
handlebars: handlebars:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:

3246
build/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,21 +9,20 @@
"private": true, "private": true,
"homepage": "https://github.com/nextcloud/", "homepage": "https://github.com/nextcloud/",
"contributors": [], "contributors": [],
"dependencies": {},
"devDependencies": { "devDependencies": {
"handlebars": "^4.7.6", "handlebars": "^4.7.6",
"jasmine-core": "~2.5.2", "jasmine-core": "~2.5.2",
"jasmine-sinon": "^0.4.0", "jasmine-sinon": "^0.4.0",
"jsdoc": "^3.6.6", "jsdoc": "^3.6.6",
"karma": "^3.1.4", "karma": "^5.2.3",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "2.0.1", "karma-coverage": "2.0.1",
"karma-jasmine": "^1.1.2", "karma-jasmine": "^1.1.2",
"karma-jasmine-sinon": "^1.0.4", "karma-jasmine-sinon": "^1.0.4",
"karma-junit-reporter": "^1.2.0", "karma-spec-reporter": "^0.0.32",
"karma-phantomjs-launcher": "^1.0.4",
"karma-viewport": "^1.0.7", "karma-viewport": "^1.0.7",
"node-sass": "~4.14.1", "node-sass": "~4.14.1",
"phantomjs-prebuilt": "*", "puppeteer": "^5.5.0",
"sinon": "<= 5.0.7" "sinon": "<= 5.0.7"
}, },
"engine": "node >= 6.9" "engine": "node >= 6.9"

View File

@ -2,15 +2,6 @@
"libraries": [ "libraries": [
], ],
"modules": [ "modules": [
"share.js",
"sharetemplates.js",
"sharesocialmanager.js",
"shareconfigmodel.js",
"shareitemmodel.js",
"sharedialogview.js",
"sharedialoglinkshareview.js",
"sharedialogresharerinfoview.js",
"sharedialogshareelistview.js",
"public/publicpage.js", "public/publicpage.js",
"setupchecks.js", "setupchecks.js",
"mimetype.js", "mimetype.js",

View File

@ -117,6 +117,7 @@ window.Snap.prototype = {
}; };
window.isPhantom = /phantom/i.test(navigator.userAgent); window.isPhantom = /phantom/i.test(navigator.userAgent);
document.documentElement.lang = navigator.language;
// global setup for all tests // global setup for all tests
(function setupTests() { (function setupTests() {

View File

@ -38,8 +38,8 @@ describe('jquery.avatar tests', function() {
it('undefined', function() { it('undefined', function() {
$div.avatar('foo'); $div.avatar('foo');
expect($div.height()).toEqual(64); expect(Math.round($div.height())).toEqual(64);
expect($div.width()).toEqual(64); expect(Math.round($div.width())).toEqual(64);
}); });
it('undefined but div has height', function() { it('undefined but div has height', function() {
@ -49,8 +49,8 @@ describe('jquery.avatar tests', function() {
expect(window.Image).toHaveBeenCalled(); expect(window.Image).toHaveBeenCalled();
window.Image().onerror(); window.Image().onerror();
expect($div.height()).toEqual(9); expect(Math.round($div.height())).toEqual(9);
expect($div.width()).toEqual(9); expect(Math.round($div.width())).toEqual(9);
}); });
it('undefined but data size is set', function() { it('undefined but data size is set', function() {
@ -60,8 +60,8 @@ describe('jquery.avatar tests', function() {
expect(window.Image).toHaveBeenCalled(); expect(window.Image).toHaveBeenCalled();
window.Image().onerror(); window.Image().onerror();
expect($div.height()).toEqual(10); expect(Math.round($div.height())).toEqual(10);
expect($div.width()).toEqual(10); expect(Math.round($div.width())).toEqual(10);
}); });
@ -71,8 +71,8 @@ describe('jquery.avatar tests', function() {
expect(window.Image).toHaveBeenCalled(); expect(window.Image).toHaveBeenCalled();
window.Image().onerror(); window.Image().onerror();
expect($div.height()).toEqual(8); expect(Math.round($div.height())).toEqual(8);
expect($div.width()).toEqual(8); expect(Math.round($div.width())).toEqual(8);
}); });
}); });

View File

@ -33,6 +33,10 @@
* preprocessor, which is needed to be able to debug tests properly in a browser. * preprocessor, which is needed to be able to debug tests properly in a browser.
*/ */
if (!process.env.CHROMIUM_BIN) {
process.env.CHROMIUM_BIN = require('puppeteer').executablePath()
}
/* jshint node: true */ /* jshint node: true */
module.exports = function(config) { module.exports = function(config) {
function findApps() { function findApps() {
@ -56,7 +60,6 @@ module.exports = function(config) {
'apps/files_sharing/js/dist/files_sharing_tab.js', 'apps/files_sharing/js/dist/files_sharing_tab.js',
'apps/files_sharing/js/dist/files_sharing.js', 'apps/files_sharing/js/dist/files_sharing.js',
'apps/files_sharing/js/dist/main.js', 'apps/files_sharing/js/dist/main.js',
'apps/files_sharing/js/dist/sidebar.js',
'apps/files_sharing/js/files_drop.js', 'apps/files_sharing/js/files_drop.js',
'apps/files_sharing/js/public.js', 'apps/files_sharing/js/public.js',
'apps/files_sharing/js/sharedfilelist.js', 'apps/files_sharing/js/sharedfilelist.js',
@ -189,12 +192,6 @@ module.exports = function(config) {
included: false, included: false,
served: true served: true
}); });
files.push({
pattern: 'core/css/images/*',
watched: false,
included: false,
served: true
});
// include core CSS // include core CSS
files.push({ files.push({
@ -237,12 +234,22 @@ module.exports = function(config) {
'/base/tests/css/': 'http://localhost:9876/base/core/css/', '/base/tests/css/': 'http://localhost:9876/base/core/css/',
'/base/core/css/images/': 'http://localhost:9876/base/core/css/images/', '/base/core/css/images/': 'http://localhost:9876/base/core/css/images/',
'/actions/': 'http://localhost:9876/base/core/img/actions/', '/actions/': 'http://localhost:9876/base/core/img/actions/',
'/base/core/fonts/': 'http://localhost:9876/base/core/fonts/' '/base/core/fonts/': 'http://localhost:9876/base/core/fonts/',
'/svg/': '../core/img/'
}, },
// test results reporter to use // test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' // possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['dots', 'junit', 'coverage'], reporters: ['spec'],
specReporter: {
maxLogLines: 5,
suppressErrorSummary: false,
suppressFailed: false,
suppressPassed: true,
suppressSkipped: true,
showSpecTiming: false,
},
junitReporter: { junitReporter: {
outputFile: 'tests/autotest-results-js.xml' outputFile: 'tests/autotest-results-js.xml'
@ -281,16 +288,8 @@ module.exports = function(config) {
// - PhantomJS // - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) // - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
// use PhantomJS_debug for extra local debug // use PhantomJS_debug for extra local debug
browsers: ['PhantomJS'], browsers: ['ChromiumHeadless'],
plugins: [
'karma-phantomjs-launcher',
'karma-coverage',
'karma-jasmine',
'karma-jasmine-sinon',
'karma-viewport',
'karma-junit-reporter'
],
// you can define custom flags // you can define custom flags
customLaunchers: { customLaunchers: {
PhantomJS_debug: { PhantomJS_debug: {