Skip to content

Commit 8a0ca56

Browse files
authored
Merge pull request turbolinks#404 from turbolinks/tests
Modernize tests
2 parents e7d089f + 31b3436 commit 8a0ca56

40 files changed

+2419
-453
lines changed

.travis.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
language: ruby
2-
cache: bundler
1+
dist: trusty
2+
sudo: false
3+
cache:
4+
- bundler
5+
- yarn
6+
script: bin/ci
37
addons:
8+
apt:
9+
sources:
10+
- sourceline: "deb https://dl.yarnpkg.com/debian/ stable main"
11+
key_url: "https://dl.yarnpkg.com/debian/pubkey.gpg"
12+
packages:
13+
- yarn
414
chrome: stable
5-
script: bin/ci

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,17 @@ $ bin/blade build
541541
542542
## Running Tests
543543
544-
Follow the instructions for _Building From Source_ above. Then run `bin/blade runner` and visit the displayed URL in your browser. The Turbolinks test suite will start automatically.
544+
The Turbolinks test suite is written in [TypeScript](https://www.typescriptlang.org) with the [Intern testing library](https://theintern.io).
545+
546+
To run the tests, first make sure you have the [Yarn package manager](https://yarnpkg.com) installed. Follow the instructions for _Building From Source_ above, then run the following commands:
547+
548+
```
549+
$ cd test
550+
$ yarn install
551+
$ yarn test
552+
```
553+
554+
If you are testing changes to the Turbolinks source, remember to run `bin/blade build` before each test run.
545555
546556
---
547557

bin/ci

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
cleanup() {
5-
try_to_kill $blade_pid
6-
try_to_kill $chrome_pid
7-
}
8-
9-
try_to_kill() {
10-
[ -n "$1" ] && { kill "$1" || true; }
11-
}
12-
13-
unset blade_pid chrome_pid
14-
trap cleanup EXIT
15-
16-
bin/blade ci &
17-
blade_pid=$!
18-
sleep 1
19-
20-
if which google-chrome-stable > /dev/null; then
21-
chrome="google-chrome-stable"
22-
else
23-
chrome="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
24-
fi
25-
26-
"$chrome" --headless --no-sandbox --remote-debugging-port=9222 http://localhost:9876 &
27-
chrome_pid=$!
28-
29-
wait $blade_pid
4+
bin/blade build
5+
cd test
6+
yarn install
7+
exec yarn test

test/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

test/.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "Run All Tests",
8+
"cwd": "${workspaceFolder}",
9+
"port": 9229,
10+
"outputCapture": "std",
11+
"internalConsoleOptions": "openOnSessionStart",
12+
"runtimeExecutable": "yarn",
13+
"runtimeArgs": ["test"]
14+
}
15+
]
16+
}

test/environment.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require("ts-node").register()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Additional assets</title>
6+
<link rel="stylesheet" type="text/css" href="/fixtures/test.css">
7+
<script src="/fixtures/turbolinks.js" data-turbolinks-track="reload"></script>
8+
<script src="/fixtures/test.js"></script>
9+
</head>
10+
<body>
11+
<h1>Additional assets</h1>
12+
</body>
13+
</html>
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Body script</title>
6-
<script src="/turbolinks.js" data-turbolinks-track="reload"></script>
6+
<script src="/fixtures/turbolinks.js" data-turbolinks-track="reload"></script>
7+
<script src="/fixtures/test.js"></script>
8+
<meta name="turbolinks-cache-control" content="no-preview">
79
</head>
810
<body>
911
<h1>Body script</h1>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<head>
44
<meta charset="utf-8">
55
<title>data-turbolinks-eval=false script</title>
6-
<script src="/turbolinks.js" data-turbolinks-track="reload"></script>
6+
<script src="/fixtures/turbolinks.js" data-turbolinks-track="reload"></script>
7+
<script src="/fixtures/test.js"></script>
78
</head>
89
<body>
910
<h1>data-turbolinks-eval=false script</h1>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Head script</title>
6-
<script src="/turbolinks.js" data-turbolinks-track="reload"></script>
6+
<script src="/fixtures/turbolinks.js" data-turbolinks-track="reload"></script>
7+
<script src="/fixtures/test.js"></script>
78
<script>
89
if ("headScriptEvaluationCount" in window) {
910
window.headScriptEvaluationCount++

0 commit comments

Comments
 (0)