From 6ee17f8e2940bf0f1c8e1f985e41c0969f31aacd Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Fri, 8 Dec 2023 19:57:27 -0800
Subject: [PATCH 1/8] Update a few more things
---
.github/workflows/ci.yaml | 6 +++---
package.json | 23 ++++++++++++-----------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index ae363a2..f3b50f4 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -12,14 +12,14 @@ on:
jobs:
test:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- name: 'Install Node.js'
uses: actions/setup-node@v1
with:
- node-version: '18.x'
+ node-version: '20.x'
- name: 'Install dependencies from npm'
run: |
npm install
@@ -42,7 +42,7 @@ jobs:
-p 4444:4444 \
--link nginx \
--shm-size=2g \
- selenium/standalone-chrome:103.0
+ selenium/standalone-chrome:119.0
# Wait 5 seconds
sleep 5
- name: 'Run tests'
diff --git a/package.json b/package.json
index 58cfe3d..d42a6fc 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"main": "Router.svelte",
"svelte": "Router.svelte",
"types": "Router.d.ts",
+ "type": "module",
"scripts": {
"build-test-app": "(cd test/app && npx rollup -c)",
"start-test-app": "npx serve -n -l 5000 test/app/dist",
@@ -31,20 +32,20 @@
},
"homepage": "https://github.com/ItalyPaleAle/svelte-spa-router#readme",
"dependencies": {
- "regexparam": "2.0.1"
+ "regexparam": "2.0.2"
},
"devDependencies": {
- "@rollup/plugin-commonjs": "^22.0.2",
- "@rollup/plugin-node-resolve": "^13.3.0",
- "chromedriver": "^103.0.0",
- "eslint": "^8.44.0",
+ "@rollup/plugin-commonjs": "^25.0.7",
+ "@rollup/plugin-node-resolve": "^15.2.3",
+ "chromedriver": "^119.0.1",
+ "eslint": "^8.55.0",
"eslint-plugin-html": "^7.1.0",
- "eslint-plugin-svelte": "^2.32.2",
- "nightwatch": "^1.7.13",
- "rollup": "^2.79.1",
- "rollup-plugin-css-only": "^3.1.0",
+ "eslint-plugin-svelte": "^2.35.1",
+ "nightwatch": "^2.6.23",
+ "rollup": "^4.7.0",
+ "rollup-plugin-css-only": "^4.5.2",
"rollup-plugin-svelte": "^7.1.6",
- "serve": "^14.2.0",
- "svelte": "^4.0.5"
+ "serve": "^14.2.1",
+ "svelte": "^4.2.8"
}
}
From ff99e63c5f6902f045f4ab44c7cf48a5ef1763f7 Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Fri, 8 Dec 2023 20:17:56 -0800
Subject: [PATCH 2/8] Fixed tests
---
Advanced Usage.md | 4 ++--
CHANGELOG.md | 2 +-
README.md | 8 ++++----
UPGRADING.md | 8 ++++++++
nightwatch.conf.js => nightwatch.conf.cjs | 0
package.json | 3 ++-
test/cases/{01-routing.test.js => 01-routing.test.cjs} | 0
...02-active-action.test.js => 02-active-action.test.cjs} | 0
...ting-with-map.test.js => 03-routing-with-map.test.cjs} | 0
9 files changed, 17 insertions(+), 8 deletions(-)
rename nightwatch.conf.js => nightwatch.conf.cjs (100%)
rename test/cases/{01-routing.test.js => 01-routing.test.cjs} (100%)
rename test/cases/{02-active-action.test.js => 02-active-action.test.cjs} (100%)
rename test/cases/{03-routing-with-map.test.js => 03-routing-with-map.test.cjs} (100%)
diff --git a/Advanced Usage.md b/Advanced Usage.md
index cd6fcbe..a507888 100644
--- a/Advanced Usage.md
+++ b/Advanced Usage.md
@@ -2,7 +2,7 @@
svelte-spa-router is simple by design. A minimal router is easy to learn and implement, adds minimum overhead, and leaves more control in the hands of the developers.
-Thanks to the many features of Svelte 3 or other components in the ecosystem, svelte-spa-router can be used to get many more "advanced" features. This document explains how to achieve certain results with svelte-spa-router beyond what's offered by the component itself.
+Thanks to the many features of Svelte or other components in the ecosystem, svelte-spa-router can be used to get many more "advanced" features. This document explains how to achieve certain results with svelte-spa-router beyond what's offered by the component itself.
- [Route wrapping](#route-wrapping), including:
- [Dynamically-imported routes and placeholders](#async-routes-and-loading-placeholders)
@@ -471,7 +471,7 @@ With the same URL as before, the result would be:
## Route transitions
-It's easy to add a nice transition between routes, leveraging the built-in [transitions](https://svelte.dev/docs#Transitions) of Svelte 3.
+It's easy to add a nice transition between routes, leveraging the built-in [transitions](https://svelte.dev/docs#Transitions) of Svelte.
For example, to make your components fade in gracefully, you can wrap the markup in a container (e.g. `
`, or ``, etc) and attach a Svelte transition to that. For example:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 37fe528..97accd2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,4 +2,4 @@
A detailed changelog for each release is published in the [GitHub Releases page](https://github.com/ItalyPaleAle/svelte-spa-router/releases).
-Additionally, breaking changes (e.g. from 1.x to 2.x) are explained in the [UPGRADING.md](/UPGRADING.md) file, with instructions to upgrade your code.
+Additionally, breaking changes (e.g. from 3.x to 4.x) are explained in the [UPGRADING.md](/UPGRADING.md) file, with instructions to upgrade your code.
diff --git a/README.md b/README.md
index 69492ef..8e60864 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,7 @@
[![npm](https://img.shields.io/npm/v/svelte-spa-router.svg)](https://www.npmjs.com/package/svelte-spa-router)
[![GitHub](https://img.shields.io/github/license/ItalyPaleAle/svelte-spa-router.svg)](https://github.com/ItalyPaleAle/svelte-spa-router/blob/master/LICENSE.md)
-This module is a router for [Svelte 3](https://github.com/sveltejs/svelte) applications, specifically optimized for Single Page Applications (SPA).
+This module is a router for [Svelte 3 and 4](https://github.com/sveltejs/svelte) applications, specifically optimized for Single Page Applications (SPA).
Main features:
@@ -38,7 +38,7 @@ With hash-based routing, navigation is possible thanks to storing the current vi
For example, if your SPA is in a static file called `index.html`, your URLs for navigating within the app look something like `index.html#/profile`, `index.html#/book/42`, etc. (The `index.html` part can usually be omitted for the index file, so you can just create URLs that look like `http://example.com/#/profile`).
-When I created this component, other routers for Svelte 3 implemented navigation using the HTML5 history API. While those URLs look nicer (e.g. you can actually navigate to `http://example.com/profile`), they are not ideal for static Single Page Applications. In order for users to be able to share links or even just refresh the page, you are required to have a server on the backend processing the request, and building fully-static apps is much harder as a consequence.
+When I created this component, other routers for Svelte 3+ implemented navigation using the HTML5 history API. While those URLs look nicer (e.g. you can actually navigate to `http://example.com/profile`), they are not ideal for static Single Page Applications. In order for users to be able to share links or even just refresh the page, you are required to have a server on the backend processing the request, and building fully-static apps is much harder as a consequence.
Hash-based routing is simpler, works well even without a server, and it's generally better suited for static SPAs, especially when SEO isn't a concern, as is the case when the app requires authentication. Many popular apps use hash-based routing, including GMail!
@@ -67,7 +67,7 @@ The sample will be running at http://localhost:5000
## Starter template
-You can find a starter template with Svelte 3 and svelte-spa-router at [italypaleale/svelte-spa-router-template](https://github.com/italypaleale/svelte-spa-router-template).
+You can find a starter template with Svelte 4 and svelte-spa-router at [italypaleale/svelte-spa-router-template](https://github.com/italypaleale/svelte-spa-router-template).
To use the template:
@@ -80,7 +80,7 @@ More information can be found on the [template's repo](https://github.com/italyp
## Using svelte-spa-router
-You can include the router in any project using Svelte 3.
+You can include the router in any project using Svelte 4.
### Install from NPM
diff --git a/UPGRADING.md b/UPGRADING.md
index a1e9edf..0939f7e 100644
--- a/UPGRADING.md
+++ b/UPGRADING.md
@@ -11,6 +11,14 @@
# Upgrading instructions
+## Upgrading to 4.x
+
+When upgrading from svelte-spa-router 3.x to 4.x, please note the following breaking changes:
+
+### Works with Svelte 4
+
+svelte-spa-router 4.x is designed to work with Svelte 4.
+
## Upgrading to 3.x
When upgrading from svelte-spa-router 2.x to 3.x, please note the following breaking changes:
diff --git a/nightwatch.conf.js b/nightwatch.conf.cjs
similarity index 100%
rename from nightwatch.conf.js
rename to nightwatch.conf.cjs
diff --git a/package.json b/package.json
index d42a6fc..6fd7851 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"start-test-app": "npx serve -n -l 5000 test/app/dist",
"eslint": "npx eslint -c .eslintrc.js --ext .js,.svelte,.html .",
"lint": "npm run eslint",
- "nightwatch": "npx nightwatch -e selenium.chrome",
+ "nightwatch": "npx nightwatch -e selenium.chrome -c nightwatch.conf.cjs",
"test": "npm run nightwatch"
},
"repository": {
@@ -21,6 +21,7 @@
"keywords": [
"router",
"svelte",
+ "svelte3",
"svelte4",
"spa"
],
diff --git a/test/cases/01-routing.test.js b/test/cases/01-routing.test.cjs
similarity index 100%
rename from test/cases/01-routing.test.js
rename to test/cases/01-routing.test.cjs
diff --git a/test/cases/02-active-action.test.js b/test/cases/02-active-action.test.cjs
similarity index 100%
rename from test/cases/02-active-action.test.js
rename to test/cases/02-active-action.test.cjs
diff --git a/test/cases/03-routing-with-map.test.js b/test/cases/03-routing-with-map.test.cjs
similarity index 100%
rename from test/cases/03-routing-with-map.test.js
rename to test/cases/03-routing-with-map.test.cjs
From 15eee9c2e9117e65e9a8515264525f3fb25eca8a Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Fri, 8 Dec 2023 20:33:38 -0800
Subject: [PATCH 3/8] Trying to fix tests
---
.devcontainer/devcontainer.json | 2 +-
README.md | 4 +-
examples/dynamic-imports/src/routes.js | 2 +-
nightwatch.conf.cjs | 2 +-
package.json | 2 +-
test/cases/01-routing.test.cjs | 74 +++++++++++++-------------
6 files changed, 44 insertions(+), 42 deletions(-)
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 87f67dc..88a5bef 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -23,7 +23,7 @@
// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [
- 5000
+ 5050
],
// Use 'postCreateCommand' to run commands after the container is created.
diff --git a/README.md b/README.md
index 8e60864..c124844 100644
--- a/README.md
+++ b/README.md
@@ -60,10 +60,10 @@ cd examples/basic-routing
# Build and run (in the folder of a sample)
npx rollup -c
-npx serve -n -l 5000 dist
+npx serve -n -l 5050 dist
````
-The sample will be running at http://localhost:5000
+The sample will be running at http://localhost:5050
## Starter template
diff --git a/examples/dynamic-imports/src/routes.js b/examples/dynamic-imports/src/routes.js
index 74b596b..751d8c1 100644
--- a/examples/dynamic-imports/src/routes.js
+++ b/examples/dynamic-imports/src/routes.js
@@ -39,7 +39,7 @@ export default {
.then((component) => {
return new Promise((resolve) => {
// Wait 5 seconds before returning
- setTimeout(() => resolve(component), 5000)
+ setTimeout(() => resolve(component), 5050)
})
}),
// Show the loading component while the component is being downloaded
diff --git a/nightwatch.conf.cjs b/nightwatch.conf.cjs
index 1eea9d1..1ea09cb 100644
--- a/nightwatch.conf.cjs
+++ b/nightwatch.conf.cjs
@@ -3,7 +3,7 @@ const seleniumHost = process.env.SELENIUM_HOST || '127.0.0.1'
const seleniumPort = parseInt(process.env.SELENIUM_PORT || '4444', 10)
// Launch URL - where the server is
-const launchUrl = process.env.LAUNCH_URL || 'http://localhost:5000'
+const launchUrl = process.env.LAUNCH_URL || 'http://localhost:5050'
// Increase max listeners to avoid a warning
require('events').EventEmitter.defaultMaxListeners = 100
diff --git a/package.json b/package.json
index 6fd7851..1f81d2e 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"type": "module",
"scripts": {
"build-test-app": "(cd test/app && npx rollup -c)",
- "start-test-app": "npx serve -n -l 5000 test/app/dist",
+ "start-test-app": "npx serve -n -l 5050 test/app/dist",
"eslint": "npx eslint -c .eslintrc.js --ext .js,.svelte,.html .",
"lint": "npm run eslint",
"nightwatch": "npx nightwatch -e selenium.chrome -c nightwatch.conf.cjs",
diff --git a/test/cases/01-routing.test.cjs b/test/cases/01-routing.test.cjs
index 7490cfa..7354b7a 100644
--- a/test/cases/01-routing.test.cjs
+++ b/test/cases/01-routing.test.cjs
@@ -8,18 +8,20 @@ describe(' component', function() {
this.timeout(4000)
it('renders on the page', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl)
.expect.element('body').to.be.present.before(1000)
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
-
- browser.end()
+ .assert.textContains('h2.routetitle', 'Home!')
})
it('current path appears', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl)
.waitForElementVisible('#currentpath')
@@ -29,12 +31,14 @@ describe(' component', function() {
})
it('selecting route from hash', (browser) => {
+ browser.restart()
+
// Main route
browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
+ .assert.textContains('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
@@ -43,7 +47,7 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/wild')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
@@ -52,95 +56,95 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
- browser.end()
})
it('loading page with hash', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
- browser.end()
})
it('refreshing page', (browser) => {
+ browser.restart()
+
// /hello/svelte
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
+
browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
- browser.end()
})
})
it('catch-all route', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl + '/#/does/not/exist')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'NotFound')
+ .assert.textContains('h2.routetitle', 'NotFound')
.expect.element('#currentpath').text.to.equal('/does/not/exist')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"wild":"does/not/exist"}')
-
- browser.end()
})
it('clicking on link', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('ul.navigation-links')
.click('.navigation-links a[href="#/hello/svelte"]', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser
.expect.element('#nameparams').text.to.equal('Your name is: svelte')
-
- browser.end()
})
})
it('clicking link with children', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl + '/#/hello/world')
.waitForElementVisible('ul.navigation-links')
.click('.navigation-links li a b', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
+ .assert.textContains('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/brand')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
-
- browser.end()
})
})
it('back and forward buttons', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl + '/#/hello/svelte/user')
.waitForElementVisible('ul.navigation-links')
@@ -166,28 +170,26 @@ describe(' component', function() {
browser
.waitForElementVisible('#nameparams')
.expect.element('#nameparams').text.to.equal('Your name is: svelte')
-
- browser.end()
})
})
})
})
it('push method', (browser) => {
+ browser.restart()
+
browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('p.navigation-buttons')
.click('.navigation-buttons button:nth-of-type(1)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.expect.element('#currentparams').text.to.equal('{"wild":"something"}')
browser.url((url) => {
assert.strictEqual(url.value, browser.launchUrl + '/#/wild/something')
-
- browser.end()
})
})
})
@@ -204,7 +206,7 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.url((url) => {
@@ -228,7 +230,7 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(3)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/replaced')
browser.url((url) => {
@@ -240,7 +242,7 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.url((url) => {
@@ -260,7 +262,7 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte?search=query&sort=0')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')
@@ -268,7 +270,7 @@ describe(' component', function() {
browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')
@@ -318,7 +320,7 @@ describe(' component', function() {
// Condition always fails
browser.url(browser.launchUrl + '/#/lucky?pass=0')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/conditions-failed')
browser.expect.element('#currentqs').text.to.equal('')
From b8b7c05fe21232d4bb6b3bf68fbe31169a732f6b Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Fri, 8 Dec 2023 20:40:21 -0800
Subject: [PATCH 4/8] Revert changes to test/cases
---
test/cases/01-routing.test.cjs | 74 +++++++++++++++++-----------------
1 file changed, 36 insertions(+), 38 deletions(-)
diff --git a/test/cases/01-routing.test.cjs b/test/cases/01-routing.test.cjs
index 7354b7a..7490cfa 100644
--- a/test/cases/01-routing.test.cjs
+++ b/test/cases/01-routing.test.cjs
@@ -8,20 +8,18 @@ describe(' component', function() {
this.timeout(4000)
it('renders on the page', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl)
.expect.element('body').to.be.present.before(1000)
browser
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Home!')
+ .assert.containsText('h2.routetitle', 'Home!')
+
+ browser.end()
})
it('current path appears', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl)
.waitForElementVisible('#currentpath')
@@ -31,14 +29,12 @@ describe(' component', function() {
})
it('selecting route from hash', (browser) => {
- browser.restart()
-
// Main route
browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Home!')
+ .assert.containsText('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
@@ -47,7 +43,7 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/wild')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Wild')
+ .assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
@@ -56,95 +52,95 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Hi there!')
+ .assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
+
+ browser.end()
})
it('loading page with hash', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Hi there!')
+ .assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
+
+ browser.end()
})
it('refreshing page', (browser) => {
- browser.restart()
-
// /hello/svelte
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Hi there!')
+ .assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
+
browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Hi there!')
+ .assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
+
+ browser.end()
})
})
it('catch-all route', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl + '/#/does/not/exist')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'NotFound')
+ .assert.containsText('h2.routetitle', 'NotFound')
.expect.element('#currentpath').text.to.equal('/does/not/exist')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"wild":"does/not/exist"}')
+
+ browser.end()
})
it('clicking on link', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('ul.navigation-links')
.click('.navigation-links a[href="#/hello/svelte"]', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Hi there!')
+ .assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser
.expect.element('#nameparams').text.to.equal('Your name is: svelte')
+
+ browser.end()
})
})
it('clicking link with children', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl + '/#/hello/world')
.waitForElementVisible('ul.navigation-links')
.click('.navigation-links li a b', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Home!')
+ .assert.containsText('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/brand')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
+
+ browser.end()
})
})
it('back and forward buttons', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl + '/#/hello/svelte/user')
.waitForElementVisible('ul.navigation-links')
@@ -170,26 +166,28 @@ describe(' component', function() {
browser
.waitForElementVisible('#nameparams')
.expect.element('#nameparams').text.to.equal('Your name is: svelte')
+
+ browser.end()
})
})
})
})
it('push method', (browser) => {
- browser.restart()
-
browser
.url(browser.launchUrl + '/#/')
.waitForElementVisible('p.navigation-buttons')
.click('.navigation-buttons button:nth-of-type(1)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Wild')
+ .assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.expect.element('#currentparams').text.to.equal('{"wild":"something"}')
browser.url((url) => {
assert.strictEqual(url.value, browser.launchUrl + '/#/wild/something')
+
+ browser.end()
})
})
})
@@ -206,7 +204,7 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Wild')
+ .assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.url((url) => {
@@ -230,7 +228,7 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(3)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Wild')
+ .assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/replaced')
browser.url((url) => {
@@ -242,7 +240,7 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Wild')
+ .assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.url((url) => {
@@ -262,7 +260,7 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte?search=query&sort=0')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Hi there!')
+ .assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')
@@ -270,7 +268,7 @@ describe(' component', function() {
browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Hi there!')
+ .assert.containsText('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')
@@ -320,7 +318,7 @@ describe(' component', function() {
// Condition always fails
browser.url(browser.launchUrl + '/#/lucky?pass=0')
.waitForElementVisible('h2.routetitle')
- .assert.textContains('h2.routetitle', 'Wild')
+ .assert.containsText('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/conditions-failed')
browser.expect.element('#currentqs').text.to.equal('')
From 96982554601ac57ccb2349a96e0fc5380bd1cdbe Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Fri, 8 Dec 2023 20:50:31 -0800
Subject: [PATCH 5/8] Revert nightwatch for now
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 1f81d2e..ef9356a 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
"eslint": "^8.55.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-svelte": "^2.35.1",
- "nightwatch": "^2.6.23",
+ "nightwatch": "^1.7.13",
"rollup": "^4.7.0",
"rollup-plugin-css-only": "^4.5.2",
"rollup-plugin-svelte": "^7.1.6",
From e91ad7384e603fa9113680fe8280cce0cfbf7a7b Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Sat, 9 Dec 2023 04:59:01 +0000
Subject: [PATCH 6/8] Revert "Revert nightwatch for now"
This reverts commit 96982554601ac57ccb2349a96e0fc5380bd1cdbe.
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index ef9356a..1f81d2e 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
"eslint": "^8.55.0",
"eslint-plugin-html": "^7.1.0",
"eslint-plugin-svelte": "^2.35.1",
- "nightwatch": "^1.7.13",
+ "nightwatch": "^2.6.23",
"rollup": "^4.7.0",
"rollup-plugin-css-only": "^4.5.2",
"rollup-plugin-svelte": "^7.1.6",
From ea029cf8577db974d07b52e189c7a377e3d3df11 Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Sat, 9 Dec 2023 05:09:49 +0000
Subject: [PATCH 7/8] Fixed tests
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
---
test/cases/01-routing.test.cjs | 94 +++++++++----------------
test/cases/02-active-action.test.cjs | 11 +--
test/cases/03-routing-with-map.test.cjs | 24 ++-----
3 files changed, 40 insertions(+), 89 deletions(-)
diff --git a/test/cases/01-routing.test.cjs b/test/cases/01-routing.test.cjs
index 7490cfa..d8681b1 100644
--- a/test/cases/01-routing.test.cjs
+++ b/test/cases/01-routing.test.cjs
@@ -14,9 +14,7 @@ describe(' component', function() {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
-
- browser.end()
+ .assert.textContains('h2.routetitle', 'Home!')
})
it('current path appears', (browser) => {
@@ -24,8 +22,6 @@ describe(' component', function() {
.url(browser.launchUrl)
.waitForElementVisible('#currentpath')
.expect.element('#currentpath').text.to.equal('/')
-
- browser.end()
})
it('selecting route from hash', (browser) => {
@@ -34,7 +30,7 @@ describe(' component', function() {
.url(browser.launchUrl + '/#/')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
+ .assert.textContains('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
@@ -43,7 +39,7 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/wild')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
@@ -52,12 +48,10 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
- browser.end()
})
it('loading page with hash', (browser) => {
@@ -65,12 +59,10 @@ describe(' component', function() {
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
- browser.end()
})
it('refreshing page', (browser) => {
@@ -78,7 +70,7 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
@@ -86,12 +78,10 @@ describe(' component', function() {
browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"first":"svelte","last":null}')
-
- browser.end()
})
})
@@ -99,12 +89,10 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/does/not/exist')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'NotFound')
+ .assert.textContains('h2.routetitle', 'NotFound')
.expect.element('#currentpath').text.to.equal('/does/not/exist')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('{"wild":"does/not/exist"}')
-
- browser.end()
})
it('clicking on link', (browser) => {
@@ -114,13 +102,11 @@ describe(' component', function() {
.click('.navigation-links a[href="#/hello/svelte"]', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser
.expect.element('#nameparams').text.to.equal('Your name is: svelte')
-
- browser.end()
})
})
@@ -131,12 +117,10 @@ describe(' component', function() {
.click('.navigation-links li a b', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
+ .assert.textContains('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/brand')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#currentparams').text.to.equal('null')
-
- browser.end()
})
})
@@ -166,8 +150,6 @@ describe(' component', function() {
browser
.waitForElementVisible('#nameparams')
.expect.element('#nameparams').text.to.equal('Your name is: svelte')
-
- browser.end()
})
})
})
@@ -180,14 +162,12 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(1)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.expect.element('#currentparams').text.to.equal('{"wild":"something"}')
browser.url((url) => {
assert.strictEqual(url.value, browser.launchUrl + '/#/wild/something')
-
- browser.end()
})
})
})
@@ -204,13 +184,11 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.url((url) => {
assert.strictEqual(url.value, browser.launchUrl + '/#/wild/something')
-
- browser.end()
})
})
})
@@ -228,7 +206,7 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(3)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/replaced')
browser.url((url) => {
@@ -240,14 +218,13 @@ describe(' component', function() {
.click('.navigation-buttons button:nth-of-type(2)', () => {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/something')
browser.url((url) => {
assert.strictEqual(url.value, browser.launchUrl + '/#/wild/something')
- // Ugh the callback hell...
- browser.end()
+ // Ugh the callback hell...
})
})
})
@@ -260,7 +237,7 @@ describe(' component', function() {
browser
.url(browser.launchUrl + '/#/hello/svelte?search=query&sort=0')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')
@@ -268,11 +245,9 @@ describe(' component', function() {
browser
.refresh(() => {
browser.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('search=query&sort=0')
-
- browser.end()
})
})
@@ -285,11 +260,11 @@ describe(' component', function() {
browser.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementPresent('#logbox')
.expect.element('#logbox').text.to.equal('routeLoading - {"route":"/","location":"/","querystring":"","params":null}\nrouteLoaded - {"route":"/","location":"/","querystring":"","params":null,"name":"Home"}\nrouteLoading - {"route":"/hello/:first/:last?","location":"/hello/svelte","querystring":"","params":{"first":"svelte","last":null}}\nrouteLoaded - {"route":"/hello/:first/:last?","location":"/hello/svelte","querystring":"","params":{"first":"svelte","last":null},"name":"Name"}')
-
- browser.end()
})
- it('routeEvent event', (browser) => {
+ it('routeEvent event', async (browser) => {
+ await browser.url('about:blank')
+
// Click on the p that triggers a "routeEvent" event
browser.url(browser.launchUrl + '/#/hello/svelte')
.waitForElementPresent('p#nameparams')
@@ -298,10 +273,7 @@ describe(' component', function() {
browser
.waitForElementPresent('#logbox')
.expect.element('#logbox').text.to.equal('routeLoading - {"route":"/hello/:first/:last?","location":"/hello/svelte","querystring":"","params":{"first":"svelte","last":null}}\nrouteLoaded - {"route":"/hello/:first/:last?","location":"/hello/svelte","querystring":"","params":{"first":"svelte","last":null},"name":"Name"}\nrouteEvent - {"action":"hi","params":{"first":"svelte","last":null}}')
-
- browser.end()
})
-
})
it('route conditions', (browser) => {
@@ -318,14 +290,14 @@ describe(' component', function() {
// Condition always fails
browser.url(browser.launchUrl + '/#/lucky?pass=0')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Wild')
+ .assert.textContains('h2.routetitle', 'Wild')
.expect.element('#currentpath').text.to.equal('/wild/conditions-failed')
browser.expect.element('#currentqs').text.to.equal('')
-
- browser.end()
})
- it('conditionsFailed event', (browser) => {
+ it('conditionsFailed event', async (browser) => {
+ await browser.url('about:blank')
+
// Condition always passes
browser
.url(browser.launchUrl + '/#/lucky?pass=1')
@@ -338,11 +310,11 @@ describe(' component', function() {
browser.url(browser.launchUrl + '/#/lucky?pass=0')
.waitForElementPresent('#logbox')
.expect.element('#logbox').text.to.equal('routeLoading - {"route":"/lucky","location":"/lucky","querystring":"pass=1","userData":{"foo":"bar"},"params":null}\nrouteLoaded - {"route":"/lucky","location":"/lucky","querystring":"pass=1","userData":{"foo":"bar"},"params":{"message":"secret"},"name":"Loading"}\nrouteLoaded - {"route":"/lucky","location":"/lucky","querystring":"pass=1","userData":{"foo":"bar"},"params":null,"name":"Lucky"}\nconditionsFailed - {"route":"/lucky","location":"/lucky","querystring":"pass=0","userData":{"foo":"bar"},"params":null}\nrouteLoading - {"route":"/wild/*","location":"/wild/conditions-failed","querystring":"","params":{"wild":"conditions-failed"}}\nrouteLoaded - {"route":"/wild/*","location":"/wild/conditions-failed","querystring":"","params":{"wild":"conditions-failed"},"name":"Wild"}')
-
- browser.end()
})
- it('parameter URL-decoding', (browser) => {
+ it('parameter URL-decoding', async (browser) => {
+ await browser.url('about:blank')
+
browser
.url(browser.launchUrl + '/#/hello/Mr%20Smith')
.waitForElementVisible('#currentpath')
@@ -356,11 +328,12 @@ describe(' component', function() {
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
browser.expect.element('#currentpath').text.to.equal('/hello/Mr%2%0Smith')
- browser.expect.element('#nameparams').text.to.equal('Your name is: null')
- browser.end()
+ browser.expect.element('#nameparams').text.to.equal('Your name is: null')
})
- it('use:link vars', (browser) => {
+ it('use:link vars', async (browser) => {
+ await browser.url('about:blank')
+
// Condition always passes
browser
.url(browser.launchUrl + '/#/catalog/3')
@@ -373,8 +346,7 @@ describe(' component', function() {
.expect.element('#logbox').text.to.equal('routeLoading - {"route":"/catalog/:id?","location":"/catalog/3","querystring":"","params":{"id":"3"}}\nrouteLoaded - {"route":"/catalog/:id?","location":"/catalog/3","querystring":"","params":{"id":"3"},"name":"Catalog"}\nrouteLoading - {"route":"/catalog/:id?","location":"/catalog/4","querystring":"","params":{"id":"4"}}\nrouteLoaded - {"route":"/catalog/:id?","location":"/catalog/4","querystring":"","params":{"id":"4"},"name":"Catalog"}')
browser.expect.element('#previous').attribute('href').to.endsWith('#/catalog/3')
browser.expect.element('#next').attribute('href').to.endsWith('#/catalog/5')
- })
- browser.end()
+ })
})
it('static props', (browser) => {
@@ -382,7 +354,5 @@ describe(' component', function() {
.url(browser.launchUrl + '/#/foo')
.waitForElementVisible('#staticprop')
.expect.element('#staticprop').text.to.equal('this is static')
-
- browser.end()
})
})
diff --git a/test/cases/02-active-action.test.cjs b/test/cases/02-active-action.test.cjs
index 29de49d..98acf28 100644
--- a/test/cases/02-active-action.test.cjs
+++ b/test/cases/02-active-action.test.cjs
@@ -20,8 +20,6 @@ describe('use:active action', function() {
.elements('css selector', 'ul.navigation-links li a.active[href="#/"]', (elements) => {
assert(elements)
assert.strictEqual(elements.value.length, 1)
-
- browser.end()
})
})
})
@@ -40,8 +38,6 @@ describe('use:active action', function() {
.elements('css selector', 'ul.navigation-links li a.active[href="#/hello/svelte"]', (elements) => {
assert(elements)
assert.strictEqual(elements.value.length, 1)
-
- browser.end()
})
})
})
@@ -58,8 +54,7 @@ describe('use:active action', function() {
.click('a[id=dynamic-link-1]')
.pause(1000)
//check for active class on link-1
- .expect.element('a[id=dynamic-link-1]').to.have.attribute('class').which.contains('active')
- browser.end()
+ .expect.element('a[id=dynamic-link-1]').to.have.attribute('class').which.contains('active')
})
it('inactive class', (browser) => {
@@ -79,8 +74,6 @@ describe('use:active action', function() {
.elements('css selector', 'ul.navigation-links li a.inactive', (elements) => {
assert(elements)
assert.strictEqual(elements.value.length, 1)
-
- browser.end()
})
})
})
@@ -101,8 +94,6 @@ describe('use:active action', function() {
.elements('css selector', 'ul.navigation-links li a.active', (elements) => {
assert(elements)
assert.strictEqual(elements.value.length, 0)
-
- browser.end()
})
})
})
diff --git a/test/cases/03-routing-with-map.test.cjs b/test/cases/03-routing-with-map.test.cjs
index 1c34654..cb74cce 100644
--- a/test/cases/03-routing-with-map.test.cjs
+++ b/test/cases/03-routing-with-map.test.cjs
@@ -12,9 +12,7 @@ describe(' component with routes in a Map', function() {
browser
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
-
- browser.end()
+ .assert.textContains('h2.routetitle', 'Home!')
})
it('current path appears', (browser) => {
@@ -22,8 +20,6 @@ describe(' component with routes in a Map', function() {
.url(browser.launchUrl + '/?routemap=1')
.waitForElementVisible('#currentpath')
.expect.element('#currentpath').text.to.equal('/')
-
- browser.end()
})
it('route defined as string', (browser) => {
@@ -32,7 +28,7 @@ describe(' component with routes in a Map', function() {
.url(browser.launchUrl + '/?routemap=1#/')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Home!')
+ .assert.textContains('h2.routetitle', 'Home!')
.expect.element('#currentpath').text.to.equal('/')
browser.expect.element('#currentqs').text.to.equal('')
@@ -40,11 +36,9 @@ describe(' component with routes in a Map', function() {
browser
.url(browser.launchUrl + '/?routemap=1#/hello/svelte')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Hi there!')
+ .assert.textContains('h2.routetitle', 'Hi there!')
.expect.element('#currentpath').text.to.equal('/hello/svelte')
browser.expect.element('#currentqs').text.to.equal('')
-
- browser.end()
})
it('route defined as RegExp', (browser) => {
@@ -53,7 +47,7 @@ describe(' component with routes in a Map', function() {
.url(browser.launchUrl + '/?routemap=1#/REGEX/1')
.waitForElementVisible('#currentpath')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Regex route')
+ .assert.textContains('h2.routetitle', 'Regex route')
.expect.element('#currentpath').text.to.equal('/REGEX/1')
browser.expect.element('#currentqs').text.to.equal('')
browser.expect.element('#regexmatch').text.to.equal('["/REGEX/1","1"]')
@@ -62,7 +56,7 @@ describe(' component with routes in a Map', function() {
browser
.url(browser.launchUrl + '/?routemap=1#/Match/hello/world')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Regex route')
+ .assert.textContains('h2.routetitle', 'Regex route')
.expect.element('#currentpath').text.to.equal('/Match/hello/world')
browser.expect.element('#currentqs').text.to.equal('')
// This will end at /hello because /world starts with a slash. Since the regexp doesn't have a $ character, it still matches
@@ -72,11 +66,9 @@ describe(' component with routes in a Map', function() {
browser
.url(browser.launchUrl + '/?routemap=1#/REGEX')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'NotFound')
+ .assert.textContains('h2.routetitle', 'NotFound')
.expect.element('#currentpath').text.to.equal('/REGEX')
browser.expect.element('#currentqs').text.to.equal('')
-
- browser.end()
})
it('querystring from hash', (browser) => {
@@ -85,12 +77,10 @@ describe(' component with routes in a Map', function() {
browser
.url(browser.launchUrl + '/?routemap=1#/Match/hola?hello=world')
.waitForElementVisible('h2.routetitle')
- .assert.containsText('h2.routetitle', 'Regex route')
+ .assert.textContains('h2.routetitle', 'Regex route')
.expect.element('#currentpath').text.to.equal('/Match/hola')
browser.expect.element('#currentqs').text.to.equal('hello=world')
browser.expect.element('#regexmatch').text.to.equal('["/Match/hola","Match","/hola"]')
-
- browser.end()
})
})
From cc1e21ee0554b622d0b6d6deb34e135814bf6259 Mon Sep 17 00:00:00 2001
From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
Date: Sat, 9 Dec 2023 05:12:28 +0000
Subject: [PATCH 8/8] Fixed linter
Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
---
.eslintrc.js => .eslintrc.cjs | 0
package.json | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename .eslintrc.js => .eslintrc.cjs (100%)
diff --git a/.eslintrc.js b/.eslintrc.cjs
similarity index 100%
rename from .eslintrc.js
rename to .eslintrc.cjs
diff --git a/package.json b/package.json
index 1f81d2e..ac85de0 100644
--- a/package.json
+++ b/package.json
@@ -9,7 +9,7 @@
"scripts": {
"build-test-app": "(cd test/app && npx rollup -c)",
"start-test-app": "npx serve -n -l 5050 test/app/dist",
- "eslint": "npx eslint -c .eslintrc.js --ext .js,.svelte,.html .",
+ "eslint": "npx eslint -c .eslintrc.cjs --ext .js,.svelte,.html .",
"lint": "npm run eslint",
"nightwatch": "npx nightwatch -e selenium.chrome -c nightwatch.conf.cjs",
"test": "npm run nightwatch"