Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Website which includes documentation based on Vuepress #40

Merged
merged 7 commits into from
Jul 9, 2018
Merged
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
14,657 changes: 11,685 additions & 2,972 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"main": "index.js",
"scripts": {
"ncu": "ncu",
"docs:dev": "vuepress dev website",
"docs:build": "vuepress build website",
"test": "node bin/puppy.js test --headless --",
"test-verbose": "node bin/puppy.js test --headless --verbose --",
"release": "scripts/release.sh"
Expand Down Expand Up @@ -48,5 +50,8 @@
"end-to-end",
"automation",
"web sockets"
]
],
"devDependencies": {
"vuepress": "^0.10.2"
}
}
39 changes: 39 additions & 0 deletions website/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
title: 'Puppy JS',
description: 'A framework agnostic E2E (end-to-end) testing and mocking tool for front end developers.',

themeConfig: {
repo: 'michaelthe/puppyjs',
editLinks: true,
docsDir: 'website',
lastUpdated: 'Last Updated',
nav: [
{text: 'Home', link: '/'},
{text: 'Guide', link: '/guide/'},
{text: 'Reference', link: '/config/'},
],
sidebar: {
'/guide/': genSidebarConfig('Guide', [
'',
'getting-started',
'configuration',
'testing'
]),
'/config/': genSidebarConfig('Reference', [
'',
'api',
'sockets'
])
}
}
}

function genSidebarConfig (title, children) {
return [
{
title,
collapsable: false,
children
}
]
}
201 changes: 201 additions & 0 deletions website/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
---
sidebarDepth: 2
---

# Config Reference

You can fine-tune Puppy by passing arguments to `puppy serve` and `puppy test`. Below you can find all the options.

::: danger
While for the most part the configuration options are the same for the command-line and config file some arguments cannot be passed in command line and vice-versa.
:::

## Example command-line format

```sh
puppy serve --port 8080
```

## Default config options

::: warning
Please note that the options below are in **camelCase** whereas command-line arguments are passed in using **kebab-case**.
In the config file snapshot below, what you see there are the `default` values.
:::

```javascript
// puppy.config.js

const path = require('path')

module.exports = {
// General config options
port: 8080,
verbose: false,
headless: false,
indexFile: 'index.html',
staticDir: path.resolve(process.cwd(), 'dist')
extPrefix: 'pup',

// Web socket options
ws: path.resolve(process.cwd(), 'puppy.ws.js'),
wsUrl: '/ws',
wsPort: 8080,

// API options
api: path.resolve(process.cwd(), 'puppy.api.js'),
apiPort: 8080,

// Puppeteer options
devtools: true,
windowWidth: 1920,
windowHeight: 1080,
viewportWidth: 1300,
viewportHeight: 1080
}

```

## General config options

### port

- Type: `number`
- Default: `8080`

This sets the port for all servers (Websocket, API, Static files) except the internal server app.

### verbose

- Type: `boolean`
- Default: `false`

You can set this option to true if you want to have more specific logs spat out by Puppy.

### inspect

- Type: `boolean`
- Default: `false`

You can set this option to true if you want to be able to use a debugger in Puppy's source code.

### static-dir

- Type: `string`
- Default: `dist`

Define your own static dir in the current working directory for serving static assets

### index-file

- Type: `string`
- Default: `index.html`

Define your own index.html as an entrypoint in the current working directory

### ext-prefix

- Type: `string`
- Default: `pup`

Define the extension prefix for the test suites you wish to run. You can omit the `.js` part.

## Web socket options

### ws

- Type: `string`
- Default: `puppy.ws.js`

Flag for setting a custom file for the web socket definition file, Puppy needs it to be at the top level of the current directory next to package.json

### ws-port

- Type: `number`
- Default: `8080`

Flag for setting a custom port for connecting using web socket.

### ws-url

- Type: `string`
- Default: `/ws`

Set a custom url for connecting using web socket

## HTTP API options

### api

- Type: `string`
- Default: `puppy.api.js`

Flag for setting a custom file for the HTTP API definition file. Note this file needs to be at the top level of the current working directory next to the package.json file.

### api-port

- Type: `number`
- Default: `8080`

Flag for setting a custom port for connecting using HTTP

## Puppeteer options

### headless

- Type: `boolean`
- Default: `false`

You can set this option to true if you want avoid showing a browser window when running end-to-end tests.

### devtools

- Type: `boolean`
- Default: `true`

Whether devtools should be open when running tests

### window-height

- Type: `number`
- Default: `1920`

Defines the window height when running tests.

::: danger
Can only be passed in a configuration file. i.e `puppy.ws.js`
:::

### window-width

- Type: `number`
- Default: `1080`

Defines the window width when running tests.

::: danger
Can only be passed in a configuration file. i.e `puppy.ws.js`
:::

### viewport-height

- Type: `number`
- Default: `1080`

Defines the window height when running tests. This is the height inside the browser page.

::: danger
Can only be passed in a configuration file. i.e `puppy.ws.js`
:::

### viewport-width

- Type: `number`
- Default: `1920`

Defines the viewport width when running tests. This is the width inside the browser page.
Beware that if devtools are enabled, you need to compensate for the width lost. From our tests the devtools default width is about 580px.

::: danger
Can only be passed in a configuration file. i.e `puppy.ws.js`
:::
9 changes: 9 additions & 0 deletions website/config/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebarDepth: 2
---

# API File Reference

::: tip
Coming soon
:::
9 changes: 9 additions & 0 deletions website/config/sockets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
sidebarDepth: 2
---

# Socket File Reference

::: tip
Coming soon
:::
24 changes: 24 additions & 0 deletions website/guide/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Introduction
---

# Introduction

PuppyJS is a framework agnostic E2E (end-to-end) testing and mocking tool for front end developers.
Puppy depends on [Jest](http://jestjs.io/) for tests and [Puppeteer](https://github.com/GoogleChrome/puppeteer)
for the testing environment so if you know these tools then you already know 80% of Puppy.

Puppy also lets you mock HTTP APIs and web socket events so you can
develop your application until the backend is ready as well as
run your E2E tests against the same mock API and socket events you used for development.

## How it works

Puppy creates four servers with three of the four on the **same** port. It supports both HTTP and Web sockets for mocking and it supports serving static files as well.
However, to avoid conflicts with Puppy internal routes, there is also an internal server which Puppy will proxy requests made by the tool.

For example Puppy handles a `/register` route for dynamically registering HTTP responses. **This means that if your app
was using a `/register` for registering users, it wouldn't work.** Instead of namespacing the Puppy's specific routes,
we chose to have an internal server handle that which automatically choses a free port in the 65000+ range and saves it in a `.puppy` folder in the current directory.

`.puppy` folder is used for directory specific settings by Puppy. For now it only saves the current internal server port. **Remember** to exclude this folder from `.gitignore`.
Loading