Skip to content

Commit 5c914dc

Browse files
committed
add lwc tests
1 parent 620183a commit 5c914dc

31 files changed

+11929
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ npm start
3131
- [Hybrids](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/hybrids)
3232
- [Hyperapp](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/hyperapp)
3333
- [HyperHTML](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/hyperhtml)
34+
- [Lit](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/lit)
35+
- [LWC](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/lwc)
3436
- [Mithril](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/mithril)
3537
- [Omi](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/omi)
3638
- [Polymer](https://github.com/webcomponents/custom-elements-everywhere/tree/master/libraries/polymer)

docs/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const libraryMap = {
2828
hyperapp: "Hyperapp",
2929
hyperhtml: "hyperHTML",
3030
lit: "Lit",
31+
lwc: "LWC",
3132
mithril: "Mithril",
3233
omi: "Omi",
3334
polymer: "Polymer",

libraries/lwc/.babelrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"plugins": [
3+
[
4+
"@babel/plugin-transform-runtime",
5+
{
6+
"useESModules": true
7+
}
8+
]
9+
]
10+
}

libraries/lwc/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org

libraries/lwc/karma.conf.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/**
2+
* @license
3+
* Copyright 2017 Google Inc. All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const path = require('path');
19+
const LwcWebpackPlugin = require('lwc-webpack-plugin');
20+
21+
module.exports = function(config) {
22+
config.set({
23+
plugins: [
24+
'karma-chrome-launcher',
25+
'karma-firefox-launcher',
26+
require(path.resolve(__dirname, '../__shared__/karma-plugins/karma-mocha')),
27+
'karma-sourcemap-loader',
28+
'karma-webpack',
29+
require(path.resolve(__dirname, '../__shared__/karma-plugins/karma-custom-html-reporter')),
30+
require(path.resolve(__dirname, '../__shared__/karma-plugins/karma-custom-json-reporter'))
31+
],
32+
browsers: ['ChromeHeadless', 'FirefoxHeadless'], // run in Chrome and Firefox
33+
customLaunchers: {
34+
FirefoxHeadless: {
35+
base: 'Firefox',
36+
flags: [ '-headless' ],
37+
displayName: 'FirefoxHeadless'
38+
},
39+
},
40+
singleRun: true, // set this to false to leave the browser open
41+
frameworks: ['mocha'], // use the mocha test framework
42+
files: [
43+
'tests.webpack.js' // just load this file
44+
],
45+
preprocessors: {
46+
'tests.webpack.js': ['webpack', 'sourcemap'] // preprocess with webpack and our sourcemap loader
47+
},
48+
reporters: ['dots', 'custom-html', 'custom-json'], // report results in these formats
49+
htmlReporter: {
50+
outputFile: path.resolve(__dirname, './results/results.html'),
51+
pageTitle: 'LWC + Custom Elements',
52+
groupSuites: true,
53+
useCompactStyle: true
54+
},
55+
jsonResultReporter: {
56+
outputFile: path.resolve(__dirname, './results/results.json')
57+
},
58+
webpack: { // kind of a copy of your webpack config
59+
mode: 'development',
60+
// devtool: 'inline-source-map', // just do inline source maps instead of the default
61+
resolve: {
62+
modules: [
63+
path.resolve(__dirname, '../__shared__/webcomponents/src'),
64+
path.resolve(__dirname, './node_modules')
65+
]
66+
},
67+
plugins: [
68+
new LwcWebpackPlugin({
69+
modules: [
70+
{ dir: "src/modules" }
71+
]
72+
})
73+
],
74+
module: {
75+
rules: [
76+
{
77+
test: /\.js$/,
78+
exclude: /node_modules/,
79+
use: {
80+
loader: 'babel-loader'
81+
}
82+
}
83+
]
84+
}
85+
},
86+
webpackServer: {
87+
// noInfo: true // please don't spam the console when running in karma!
88+
}
89+
});
90+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"success": 24,
3+
"failed": 8,
4+
"skipped": 0,
5+
"error": false,
6+
"disconnected": false,
7+
"exitCode": 1,
8+
"score": 89,
9+
"basicSupport": {
10+
"total": 16,
11+
"failed": 0,
12+
"passed": 16
13+
},
14+
"advancedSupport": {
15+
"total": 16,
16+
"failed": 8,
17+
"passed": 8
18+
}
19+
}

libraries/lwc/meta/issues.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[
2+
{
3+
"link": "https://github.com/salesforce/lwc/issues/1904",
4+
"title": "Unnecessary event name restrictions (such as prohibiting hyphens) should be removed",
5+
"meta": "#1904 opened May 28, 2020 by JanMiksovsky"
6+
}
7+
]

libraries/lwc/meta/summary.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<h4 id="lwc-handling-data">Handling data</h4>
2+
3+
When passing data to a custom element, LWC takes a properties-if-available approach where attributes
4+
are set by default, but properties are set when they exist. This heuristical approach involves a
5+
runtime check to see whether a property is defined, and as such, data will be passed as an attribute
6+
if the custom element has not been upgraded. It is the responsibility of the component author to
7+
handle this scenario.
8+
9+
<h4 id="lwc-handling-events">Handling events</h4>
10+
11+
LWC has no restrictions on event names when listening for events imperatively via the
12+
`addEventListener()` API. When listening for events declaratively in the template, LWC supports
13+
neither arbitrarily capitalized event names (camelCase, CAPSCase, PascalCase, etc.) nor kebab-cased
14+
names.

0 commit comments

Comments
 (0)