Skip to content

Commit

Permalink
Merge branch 'main' into remove-webpagetest
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Dec 30, 2023
2 parents 0e8aa77 + c6399c8 commit 9e9b4e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions bin/sitespeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ async function start() {
}

if (
!budgetFailing ||
(parsed.options.budget && parsed.options.budget.suppressExitCode)
(!budgetFailing ||
(parsed.options.budget && parsed.options.budget.suppressExitCode)) &&
process.exitCode === undefined
) {
process.exitCode = 0;
}
Expand Down
12 changes: 6 additions & 6 deletions docs/documentation/sitespeed.io/prepostscript/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ We use the NodeJS version of Selenium, you can find the [API documentation here]
Your script needs to follow a specific pattern to be able to run as a pre/post script. The simplest version of a script looks like this:

~~~javascript
module.exports = async function(context, commands) {
// add your own code here
}
export default async function (context, commands) {
// add your own code here
};
~~~

Move on to read about the data that is passed in the context object and how you can use it to get hold of the Selenium objects you need to interact with the page.
Expand Down Expand Up @@ -58,7 +58,7 @@ The commands object:
In your script you can get hold of the log object from sitespeed.io. This is super useful when you want to test your script and verify that everything works as it should. We use [intel](https://www.npmjs.com/package/intel) for logging.

~~~javascript
module.exports = async function(context, commands) {
export default async function (context, commands) {
// Simple example to add a log message
// Remember that you can log message on different levels
context.log.info('Log message from the task');
Expand All @@ -69,7 +69,7 @@ module.exports = async function(context, commands) {
Create a script where you login the user. The following is an example to login the user at Wikipedia. Start by creating a file login.js with the following.

~~~javascript
module.exports = async function(context, commands) {
export default async function (context, commands) {
await commands.navigate(
'https://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Main+Page'
);
Expand All @@ -91,7 +91,7 @@ Make sure to change the username & password if you try this on Wikipedia. And of
Then run it like this:

~~~bash
docker run --rm -v "$(pwd):/sitespeed.io" sitespeedio/sitespeed.io:{% include version/sitespeed.io.txt %} --preScript /sitespeed.io/login.js https://en.wikipedia.org/wiki/Barack_Obama
docker run --rm -v "$(pwd):/sitespeed.io" sitespeedio/sitespeed.io:{% include version/sitespeed.io.txt %} --preScript /sitespeed.io/login.mjs https://en.wikipedia.org/wiki/Barack_Obama
~~~

The script will then login the user and access https://en.wikipedia.org/wiki/Barack_Obama and measure that page.
Expand Down

0 comments on commit 9e9b4e2

Please sign in to comment.