name: 'Bstack-[Nightwatch] Vue Router Parallel Test',
'browserstack.local': true,
'browserstack.video': false,
+ // useful to get visual logs
+ // 'browserstack.debug': true,
acceptSslCerts: true,
resolution: '1024x768',
},
function adaptArgv(argv) {
// take every remaining argument and treat it as a test file
// this allows to run `node e2e/runner.js test/e2e/basic.js`
- argv.retries = 1
+ // argv.retries = 1
argv.test = argv['_'].slice(0)
if (argv.c === DEFAULT_CONFIG && argv.config === DEFAULT_CONFIG) {
<li>
<router-link to="/">/</router-link>
</li>
- <li>
- <!-- <router-link to="/n/€">/n/€</!-->
- -->
- </li>
<li>
<router-link to="/documents/%E2%82%AC"
>/documents/%E2%82%AC</router-link
<li>
<router-link
:to="{ name: 'home', query: { currency: '€uro', 'é': 'e' }}"
- >/currency=€uro&é=e (object)</router-link
+ >/?currency=€uro&é=e (object)</router-link
>
</li>
<li>
- <a href="/n/%E2%82%AC">/n/%E2%82%AC (force reload)</a>
+ <a href="/encoding/n/%E2%82%AC">/n/%E2%82%AC (force reload)</a>
</li>
<li>
- <a href="/n/€">/n/€ (force reload): not valid tho</a>
+ <a href="/encoding/n/€">/n/€ (force reload): not valid tho</a>
</li>
</ul>
template: `<div>Document: {{ $route.params.id }}</div>`,
}
-console.log('/' + __dirname)
-
const router = new Router({
history: createHistory('/' + __dirname),
routes: [
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+ <title>Vue Router Examples - Hash</title>
+ <!-- TODO: replace with local imports for promises and anything else needed -->
+ <script src="https://polyfill.io/v3/polyfill.min.js?features=default%2Ces2015"></script>
+ </head>
+ <body>
+ <div id="app">
+ <section class="info">
+ Name:
+ <pre id="name">{{ $route.name }}</pre>
+ </section>
+
+ <section class="info">
+ Params:
+ <pre id="params">{{ $route.params }}</pre>
+ </section>
+
+ <section class="info">
+ Query:
+ <pre id="query">{{ $route.query }}</pre>
+ </section>
+
+ <section class="info">
+ Hash:
+ <pre id="hash">{{ $route.hash }}</pre>
+ </section>
+
+ <section class="info">
+ FullPath:
+ <pre id="fullPath">{{ $route.fullPath }}</pre>
+ </section>
+
+ <section class="info">
+ path:
+ <pre id="path">{{ $route.path }}</pre>
+ </section>
+
+ <hr />
+
+ <ul>
+ <li>
+ <router-link to="/">/</router-link>
+ </li>
+ <li>
+ <router-link to="/documents/%E2%82%AC"
+ >/documents/%E2%82%AC</router-link
+ >
+ </li>
+ <li>
+ <router-link :to="{ name: 'docs', params: { id: '€uro' }}"
+ >/documents/€uro (object)</router-link
+ >
+ </li>
+ <li>
+ <router-link
+ :to="{ name: 'home', query: { currency: '€uro', 'é': 'e' }}"
+ >/?currency=€uro&é=e (object)</router-link
+ >
+ </li>
+ <li>
+ <a href="/encoding/n/%E2%82%AC">/n/%E2%82%AC (force reload)</a>
+ </li>
+ <li>
+ <a href="/encoding/n/€">/n/€ (force reload): not valid tho</a>
+ </li>
+ </ul>
+
+ <router-view></router-view>
+ </div>
+ </body>
+</html>
--- /dev/null
+import { Router, plugin, createHashHistory } from '../../src'
+import { RouteComponent } from '../../src/types'
+import Vue from 'vue'
+
+const component: RouteComponent = {
+ template: `<div>A component</div>`,
+}
+
+const Home: RouteComponent = {
+ template: `<div>Home</div>`,
+}
+
+const Document: RouteComponent = {
+ template: `<div>Document: {{ $route.params.id }}</div>`,
+}
+
+const router = new Router({
+ history: createHashHistory('/' + __dirname),
+ routes: [
+ { path: '/', component: Home, name: 'home' },
+ { path: '/documents/:id', name: 'docs', component: Document },
+ { path: encodeURI('/n/€'), name: 'euro', component },
+ ],
+})
+
+// use the router
+Vue.use(plugin)
+
+// @ts-ignore
+window.vm = new Vue({
+ el: '#app',
+ // @ts-ignore
+ router,
+})
+// @ts-check
const fs = require('fs')
const { resolve, join } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')
-const outputPath = resolve(__dirname, '__build__')
+/** @type {string[]} */
+let examples = []
+fs.readdirSync(__dirname).forEach(dir => {
+ const fullDir = join(__dirname, dir)
+ const entry = join(fullDir, 'index.ts')
+ if (fs.statSync(fullDir).isDirectory() && fs.existsSync(entry)) {
+ examples.push(dir)
+ }
+})
module.exports = {
// Expose __dirname to allow automatically setting basename.
devServer: {
// contentBase: outputPath,
historyApiFallback: {
- rewrites: [{ from: /^\/encoding(?:\/?|\/.*)$/, to: '/encoding.html' }],
+ rewrites: examples.map(name => ({
+ from: new RegExp(`^/${name}(?:\\/?|/.*)$`),
+ to: `/${name}.html`,
+ })),
+ // rewrites: [
+ // { from: /^\/encoding(?:\/?|\/.*)$/, to: '/encoding.html' },
+ // { from: /^\/hash(?:\/?|\/.*)$/, to: '/hash.html' },
+ // ],
},
// hot: true,
},
- entry: {
- encoding: resolve(__dirname, 'encoding/index.ts'),
- },
+ entry: examples.reduce((entries, name) => {
+ entries[name] = resolve(__dirname, name, 'index.ts')
+ return entries
+ }, {}),
+ // entry: {
+ // encoding: resolve(__dirname, 'encoding/index.ts'),
+ // hash: resolve(__dirname, 'hash/index.ts'),
+ // },
// entry: fs.readdirSync(__dirname).reduce((entries, dir) => {
// const fullDir = path.join(__dirname, dir)
// const entry = path.join(fullDir, 'index.ts')
extensions: ['.ts', '.tsx', '.js'],
},
plugins: [
- new HtmlWebpackPlugin({
- // inject: false,
- // chunks: ['encoding'],
- filename: 'encoding.html',
- title: 'Vue Router Examples - encoding',
- template: resolve(__dirname, 'encoding/index.html'),
- }),
+ ...examples.map(
+ name =>
+ new HtmlWebpackPlugin({
+ filename: `${name}.html`,
+ chunks: [name],
+ template: resolve(__dirname, name, 'index.html'),
+ })
+ ),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
"test:unit": "jest --coverage",
"test": "yarn run test:types && yarn run test:unit && yarn build",
"build": "yarn rollup -c rollup.config.js",
- "dev": "webpack-dev-server --mode=development"
+ "dev": "webpack-dev-server --mode=development",
+ "dev:examples": "webpack-dev-server --mode=development --config examples/webpack.config.js"
},
"devDependencies": {
"@types/jest": "^24.0.18",