Skip to content
Permalink
Browse files

Cleanup (#6)

* add CODE_OF_CONDUCT

* prettier updates

* add CONTRIBUTING

* update gitignore

* update package.json description

* update READMEs
  • Loading branch information...
trevor-bliss committed May 28, 2019
1 parent 0d381b9 commit ffb22cdb5f9271f2711fa2797d87170b62057cae
@@ -6,3 +6,4 @@ node_modules/
coverage/
.idea/
.project/
.vscode/
@@ -0,0 +1,105 @@
# Salesforce Open Source Community Code of Conduct

## About the Code of Conduct

Equality is a core value at Salesforce. We believe a diverse and inclusive
community fosters innovation and creativity, and are committed to building a
culture where everyone feels included.

Salesforce open-source projects are committed to providing a friendly, safe, and
welcoming environment for all, regardless of gender identity and expression,
sexual orientation, disability, physical appearance, body size, ethnicity, nationality,
race, age, religion, level of experience, education, socioeconomic status, or
other similar personal characteristics.

The goal of this code of conduct is to specify a baseline standard of behavior so
that people with different social values and communication styles can work
together effectively, productively, and respectfully in our open source community.
It also establishes a mechanism for reporting issues and resolving conflicts.

All questions and reports of abusive, harassing, or otherwise unacceptable behavior
in a Salesforce open-source project may be reported by contacting the Salesforce
Open Source Conduct Committee at ossconduct@salesforce.com.

## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of gender
identity and expression, sexual orientation, disability, physical appearance,
body size, ethnicity, nationality, race, age, religion, level of experience, education,
socioeconomic status, or other similar personal characteristics.

## Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy toward other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Personal attacks, insulting/derogatory comments, or trolling
* Public or private harassment
* Publishing, or threatening to publish, others' private information—such as
a physical or electronic address—without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
* Advocating for or encouraging any of the above behaviors

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned with this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project email
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the Salesforce Open Source Conduct Committee
at ossconduct@salesforce.com. All complaints will be reviewed and investigated
and will result in a response that is deemed necessary and appropriate to the
circumstances. The committee is obligated to maintain confidentiality with
regard to the reporter of an incident. Further details of specific enforcement
policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership and the Salesforce Open Source Conduct
Committee.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][contributor-covenant-home],
version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html.
It includes adaptions and additions from [Go Community Code of Conduct][golang-coc],
[CNCF Code of Conduct][cncf-coc], and [Microsoft Open Source Code of Conduct][microsoft-coc].

This Code of Conduct is licensed under the [Creative Commons Attribution 3.0 License][cc-by-3-us].

[contributor-covenant-home]: https://www.contributor-covenant.org (https://www.contributor-covenant.org/)
[golang-coc]: https://golang.org/conduct
[cncf-coc]: https://github.com/cncf/foundation/blob/master/code-of-conduct.md
[microsoft-coc]: https://opensource.microsoft.com/codeofconduct/
[cc-by-3-us]: https://creativecommons.org/licenses/by/3.0/us/
@@ -0,0 +1,21 @@
# Contributing

Before contributing to this repository make sure to discuss first the intended changes either by creating a new issue or commenting an existing one.

## Useful commands

Once the repository has been cloned you can run the following commands from the root directory.

```sh
$ yarn install # install project dependencies
$ yarn lint # run linting against project code
$ yarn test # run test
```

## Submitting code

Any code change should be submitted as a pull request. The description should explain what the code does and give steps to execute it. The pull request should also contain tests.

## Review process

The bigger the pull request, the longer it will take to review and merge. Try to break down large pull requests in smaller chunks that are easier to review and merge. Also make sure to reference the related issues in the pull request message if any.
@@ -1,7 +1,7 @@
{
"name": "lwc-test",
"private": true,
"description": "LWC Test plugins and utilities",
"description": "LWC test plugins and utilities",
"main": "index.js",
"scripts": {
"test": "jest --config ./scripts/jest/root.config.js",
@@ -1,6 +1,6 @@
# lwc-jest-preset
# @lwc/jest-preset

Tools to assist with testing Lightning Web Components (LWC) with Jest. This project provides 2 services: preset Jest configuration for testing LWC components, and stubs for common external libraries used in LWC components.
Tools to assist with testing Lightning Web Components (LWC) with Jest. This project provides 2 services: preset Jest configuration for testing Lightning web components, and stubs for common external libraries used in Lightning web components.

## Requirements

@@ -12,20 +12,20 @@ Tools to assist with testing Lightning Web Components (LWC) with Jest. This proj

### Jest Preset Configuration

1. Install `lwc-jest-transformer`. This package runs LWC components through the LWC compiler.
1. Install `@lwc/jest-transformer`. This package runs LWC components through the LWC compiler.

`yarn add -D lwc-jest-transformer`
`yarn add -D @lwc/jest-transformer`

1. Install `@lwc/jest-resolver`. This package resolves all supported `lwc-*` imports.

`yarn add -D lwc-jest-resolver`
`yarn add -D @lwc/jest-resolver`

1. Use this project's preset config. This maps to the settings in `jest-preset.json`. Any settings added to your project's own `jest` config will take precedence to entries in the preset.

```json
{
"jest": {
"preset": "lwc-jest-preset"
"preset": "@lwc/jest-preset"
}
}
```
@@ -35,7 +35,7 @@ Tools to assist with testing Lightning Web Components (LWC) with Jest. This proj
```json
{
"moduleNameMapper": {
"^(example|other)-(.+)$": "<rootDir>/src/test/modules/$1/$2/$2"
"^(example|other)/(.+)$": "<rootDir>/src/test/modules/$1/$2/$2"
}
}
```
@@ -9,15 +9,17 @@ const fs = require('fs');
const vm = require('vm');
const JSDOMEnvironment = require('jest-environment-jsdom-fifteen');
const polyfillFile = require.resolve('@lwc/synthetic-shadow');
const polyfillSource = fs.readFileSync(polyfillFile, 'utf-8')
const polyfillSource = fs.readFileSync(polyfillFile, 'utf-8');
const polyfillScript = vm.createScript(polyfillSource, '@lwc/synthetic-shadow');

/** Synthetic Shadow Polyfill should be installed only once per worker */
function _syntheticShadow(env) {
if (env.dom) {
env.dom.runVMScript(polyfillScript);
// eslint-disable-next-line no-func-assign
_syntheticShadow = function _syntheticShadow() { /* noop */ };
_syntheticShadow = function _syntheticShadow() {
/* noop */
};
}
}

@@ -32,4 +34,4 @@ module.exports = class JSDOMEnvironmentWithSyntheticShadow extends JSDOMEnvironm
this.global.ShadowRoot = this.dom.window.ShadowRoot;
this.global.HTMLSlotElement = this.dom.window.HTMLSlotElement;
}
}
};
@@ -1,3 +1,7 @@
# @lwc/jest-resolver

Resolves all supported `lwc-*` imports.

## Requirements

- Node 8.x
@@ -1,3 +1,3 @@
## jest-serializer

Standarize snapshots for shadow-dom
Standarize snapshots for Shadow DOM.
@@ -5,8 +5,8 @@
"main": "index.js",
"license": "MIT",
"keywords": [
"jest",
"lwc"
"Jest",
"LWC"
],
"dependencies": {
"pretty-format": "~24.8.0"
@@ -1,40 +1,28 @@
# lwc-jest-transformer
# @lwc/jest-transformer

Compile LWC and engine for [Jest](https://facebook.github.io/jest/) tests
Compile Lightning web components for [Jest](https://facebook.github.io/jest/) tests.

## Requirements

- Node 8.x
- NPM 5.x
- Yarn >= 1.0.0
- lwc-compiler >= 0.17.0

## Prerequisites

- `lwc-compiler` must be installed in the project.

- You may also want to install jest globally to run tests directly from the command line:

`yarn global add jest`

## Installation

`yarn add -D lwc-jest-transformer`
`yarn add -D @lwc/jest-transformer`

## Usage

1. Update your `jest` config to point the transformer to this package.
Update your `jest` config to point the transformer to this package:

```json
{
"jest": {
"moduleFileExtensions": ["js", "html"],
"transform": {
"^.+\\.(js|html)$": "lwc-jest-transformer"
"^.+\\.(js|html|css)$": "@lwc/jest-transformer"
}
}
}
```

2. Update `moduleNameMapper` to point to where your LWC modules reside in the project.
3. Follow steps 4 through 6 of Option A.
@@ -31,4 +31,4 @@
"engines": {
"node": ">=10"
}
}
}
@@ -1,47 +1,7 @@
# lwc-test-utils
# @lwc/test-utils

A collection of utility functions to assist in unit testing Lightning web components.

## Usage

Usage of this library assumes you have the a Lightning Web Component development and test environment setup. To get started with testing your Lightning web components see the [documentation website](https://internal.lwcjs.org/guide/testing.html).

### Direct Import

Add this package as a devDependency and import the utils directly into your test.

```bash
yarn add -D '@lwc/test-utils'
```
:warning: This package is for legacy purposes and likely to be removed in the near future :warning:

### Jest Preset Configuration

This util also comes pre-packed in `lwc-jest-preset`.

```bash
yarn add -D 'lwc-jest-preset'
```

In your `package.json`:

```json
"jest": {
"preset": "lwc-jest-preset",
"moduleNameMapper": {
"^(mynamespace)-(.+)$": "<rootDir>/src/$1/$2/$2"
}
}
```
A collection of utility functions to assist in unit testing Lightning web components.

Or in `jest.config.js`:

```js
const PRESET_CONFIG = require('lwc-jest-preset');
module.exports = {
...PRESET_CONFIG,
moduleNameMapper: {
...PRESET_CONFIG.moduleNameMapper,
'^(mynamespace)-(.+)$': '<rootDir>/src/$1/$2/$2',
},
};
```

0 comments on commit ffb22cd

Please sign in to comment.
You can’t perform that action at this time.