Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

MVP/pre-release #1

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
BasedOnStyle: Google
AlignAfterOpenBracket: AlwaysBreak
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BinPackArguments: false
# This breaks async functions sometimes, see
# https://github.com/Polymer/polymer-analyzer/pull/393
# BinPackParameters: false
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.vscode/
/node_modules/
/lib/
/mocha-suite-child.js
/mocha-suite-child.d.ts
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mocha-suite-child.js
rollup.config.js
tsconfig.json
tslint.json
test/
29 changes: 29 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
language: node_js
sudo: false
dist: xenial
node_js: '10'
addons:
firefox: latest
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
cache:
directories:
- node_modules
env:
global:
matrix:
fast_finish: true
allow_failures:
- env: JOB=benchmark
include:
- env: JOB=test KARMA_BROWSERS="Chrome,Firefox"
before_script:
- time npm run lint
script:
- xvfb-run time npm run test
- env: JOB=benchmark
script:
- ./travis-bench.sh
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

<!--
PRs should document their user-visible changes (if any) in the
Unreleased section, uncommenting the header as necessary.
-->

<!-- ## Unreleased -->
<!-- Add new unreleased items here -->
28 changes: 28 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2019 The Polymer Authors. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# mocha-suite-child

Intended for use when running mocha in web-browsers, runs mocha test suites defined in HTML documents and include the results as if they are part of the main context.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and includes


An example `.html` file using `mocha-suite-child` package to include 3 child suites in its run:

```html
<script src="./node_modules/mocha/mocha.js"></script>
<!-- Load mocha-suite-child right after mocha for best results. -->
<script src="./node_modules/mocha-suite-child/mocha-suite-child.js"></script>
<script src="./node_modules/chai/chai.js"></script>
<script>
// Typical mocha setup bit.
mocha.setup('tdd');

// Defines the children of the current mocha context. Note that
// the same test suite files can be reused as children, with different
// configurations. These must be defined at the top-level, i.e.
// they can't be nested within Mocha's own `suite()` declarations.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add something here about how it creates an iframe for each suiteChild?

suiteChild('Juggling apples', './juggle.html?obj=apples');
suiteChild('Juggling chainsaws', './juggle.html?obj=chainsaws');
suiteChild('Bicycling tests', './bicycling.html');

// You can still have local tests defined here if you want.
suite('A regular test suite', () => {
test('A regular test', () => {
chai.assert(true);
});
});

// Returns a MochaSuiteChild.RunnerProxy if child suites are defined.
// This is because the child suites *must* execute before the local
// runner executes in order to satisfy the reporter's expectation
// of accurate test totals. This RunnerProxy should work identically
// to a Mocha.Runner for all intents and purposes.
mocha.run();
</script>
```

64 changes: 64 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Karma configuration
// Generated on Tue Sep 24 2019 11:48:17 GMT-0700 (PDT)
const karmaBrowsers =
(process.env.KARMA_BROWSERS || '').split(/ *, */).filter(Boolean);

module.exports = function(config) {
config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',

// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'],

// list of files / patterns to load in the browser
files: ['./mocha-suite-child.js', './test/test-suite.js'],

// list of files / patterns to exclude
exclude: [],

// preprocess matching files before serving them to the browser
// available preprocessors:
// https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['spec'],

// web server port
port: 9876,

// enable / disable colors in the output (reporters and logs)
colors: false,

// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR ||
// config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file
// changes
autoWatch: true,

// start these browsers
// available browser launchers:
// https://npmjs.org/browse/keyword/karma-launcher
browsers: karmaBrowsers,

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
};

console.log('---');
console.log('KARMA_BROWSERS:', karmaBrowsers);
console.log('---');
23 changes: 23 additions & 0 deletions karma.proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* @license
* Copyright (c) 2019 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/
const Koa = require('koa');
const mount = require('koa-mount');
const staticFiles = require('koa-static');
const { nodeResolve } = require('koa-node-resolve');
const { esmTransform } = require('koa-esm-transform');

module.exports = (karma) => new Koa()
.use(esmTransform())
.use(mount('/base', new Koa().use(nodeResolve()).use(staticFiles('.'))))
.use(karma);
9 changes: 9 additions & 0 deletions koa-proxy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const Koa = require('koa');
const { nodeResolve } = require('koa-node-resolve');
const { esmTransform } = require('koa-esm-transform');
const mount = require('koa-mount');
const staticFiles = require('koa-static');
new Koa()
.use(esmTransform())
.use(mount('/base', new Koa().use(nodeResolve()).use(staticFiles('.'))))
.listen(9000);
Loading