intern.js and Browserstack - intern

Intern.js is a great testrunner but it only appears to work with SauceLabs. My company already uses BrowserStack and are very happy with it. I was wondering if anyone has been able to integrate Intern.js with BrowserStack and if so how?

You should be able to use BrowserStack with the following Intern configuration for Intern 1:
define({
capabilities: {
'browserstack.user': 'your-username',
'browserstack.key': 'your-access-key'
},
webdriver: {
host: 'hub.browserstack.com'
},
useSauceConnect: false
});
or this configuration for Intern 2:
define({
tunnel: 'BrowserStackTunnel',
tunnelOptions: {
username: 'your-username', // or use env var BROWSERSTACK_USERNAME
accessKey: 'your-access-key' // or use env var BROWSERSTACK_ACCESS_KEY
}
});

These settings work for me:
tunnel: 'BrowserStackTunnel',
webdriver: {
username: 'your-useranme',
accessKey: 'your-access-key',
},

Related

Starting Plawywright Test Browser

guys. I'm trying to set up e2e testing using Playwright. I'm following along these steps (enter link description here) and I can see the tests are passing but I'd like to see the browser window so I can try and interact with the elements. How can I make the test runner open a browser window or tab?
You could either use the Debug mode by adding --debug to you command e.g.:
npx playwright test example --debug
This allows you to Debug through your Tests step by step.
Or you can change your config to run in headed mode by setting
headless:false
In you playwright.config.ts
You can have a global configuration file called playwright.config.ts which goes in project root, a basic example of which looks like below. Note the headless: false in the 'use' section. Change the 'baseURL' to what you want to test.
// playwright.config.ts
import { PlaywrightTestConfig } from '#playwright/test';
const config: PlaywrightTestConfig = {
reporter: [['list'], ['html', { open: 'never' }]],
workers: 1,
use: {
baseURL: http://playwright.dev,
headless: false,
},
projects: [
{
name: 'chromium',
use: {
browserName: 'chromium',
},
},
],
};
export default config;
In your test, because you have a baseURL set in config, you just need to call the following to navigate to that url:
// mytest.spec.ts
import { test } from '#playwright/test';
test('Do something...', async ({ page }) => {
await page.goto('');
});

Could not load email provider "nodemailer" (Strapi)

I'm trying to setup the strapi application with nodemailer.
I've added the nodemailer dependency with yarn add #strapi/provider-email-nodemailer as on the official page described. Afterwards I've added the following configuration to my plugins.js file (I've replaced sensitive informations with XXXXXXXX):
module.exports = ({ env }) => ({
email: {
config: {
provider: 'nodemailer',
providerOptions: {
host: env('SMTP_HOST', 'XXXXXXXX'),
port: env('SMTP_PORT', 587),
auth: {
user: env('SMTP_USERNAME', 'XXXXXXXX'),
pass: env('SMTP_PASSWORD', 'XXXXXXXX'),
},
secure: true
},
settings: {
defaultFrom: 'XXXXXXXX',
defaultReplyTo: 'XXXXXXXX',
},
},
},
});
But when I try to strap Strapi with yarn develop I get the following error message:
C:\Dev\Strapi\Projects\strapi>yarn develop
yarn run v1.22.15
$ strapi develop
Building your admin UI with development configuration ...
Admin UI built successfully
[2021-12-27 23:27:51.485] debug: ⛔️ Server wasn't able to start properly.
[2021-12-27 23:27:51.487] error: Could not load email provider "nodemailer".
Error: Could not load email provider "nodemailer".
at createProvider (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\plugin-email\server\bootstrap.js:23:11)
at Object.module.exports [as bootstrap] (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\plugin-email\server\bootstrap.js:31:37)
at Object.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\core\domain\module\index.js:40:47)
at Object.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\core\registries\modules.js:28:19)
at async Strapi.runLifecyclesFunctions (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:463:5)
at async Strapi.bootstrap (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:401:5)
at async Strapi.load (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:410:5)
at async Strapi.start (C:\Dev\Strapi\Projects\strapi\node_modules\#strapi\strapi\lib\Strapi.js:161:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
What am I doing wrong? The configuration seems so simple so I don't have any idea what's wrong.
You need remove config section:
email: {
provider: 'nodemailer',
providerOptions: {
host: env('SMTP_HOST', 'smtp.xxxxxx.xx'),
port: env('SMTP_PORT', xxx),
secure: true,
auth: {
user: env('SMTP_USERNAME'),
pass: env('SMTP_PASSWORD'),
},
},
settings: {
defaultFrom: env('SMTP_FROM_EMAIL'),
defaultReplyTo: env('SMTP_REPLY_EMAIL'),
},
},
UPD: Sorry, I understood now that I use this package https://www.npmjs.com/package/strapi-provider-email-nodemailer and you used this https://www.npmjs.com/package/#strapi/provider-email-nodemailer

res.render doesn't render correctly after 1023 characters

I have a parent Express app, and a Ghost app as a child app, using Ghost as an npm module here.
I routed Ghost to be rendered at http://localhost:9000/blog. All the configuration works fine (Ghost will throw an error if the basic configuration isn't being provided correctly).
Here is my Ghost startup code
ghost({
config: path.join(__dirname, '/config/ghost.config.js')
}).then(function (ghostServer) {
app.use(ghostServer.config.paths.subdir, ghostServer.rootApp);
ghostServer.start(app);
});
here is my Ghost config
// # Ghost Configuration
// Setup your Ghost install for various [environments](http://support.ghost.org/config/#about-environments).
// Ghost runs in `development` mode by default. Full documentation can be found at http://support.ghost.org/config/
var path = require('path'),
config;
config = {
// ### Production
// When running Ghost in the wild, use the production environment.
// Configure your URL and mail settings here
production: {
url: 'http://my-ghost-blog.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
host: '127.0.0.1',
port: '2368'
}
},
// ### Development **(default)**
development: {
// The url to use when providing links to the site, E.g. in RSS and email.
// Change this to your Ghost blog's published URL.
url: 'http://localhost:9000/blog/',
// Example mail config
// Visit http://support.ghost.org/mail for instructions
// ```
// mail: {
// transport: 'SMTP',
// options: {
// service: 'Mailgun',
// auth: {
// user: '', // mailgun username
// pass: '' // mailgun password
// }
// }
// },
// ```
// #### Database
// Ghost supports sqlite3 (default), MySQL & PostgreSQL
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '../blog/data/ghost-dev.db')
},
debug: false
},
// #### Server
// Can be host & port (default), or socket
server: {
// Host to be passed to node's `net.Server#listen()`
host: '127.0.0.1',
// Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
port: '9000'
},
// #### Paths
// Specify where your content directory lives
paths: {
contentPath: path.join(__dirname, '../blog/')
}
},
// **Developers only need to edit below here**
// ### Testing
// Used when developing Ghost to run tests and check the health of Ghost
// Uses a different port number
testing: {
url: 'http://127.0.0.1:2369',
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost-test.db')
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing MySQL
// Used by Travis - Automated testing run through GitHub
'testing-mysql': {
url: 'http://127.0.0.1:2369',
database: {
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'root',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing pg
// Used by Travis - Automated testing run through GitHub
'testing-pg': {
url: 'http://127.0.0.1:2369',
database: {
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'postgres',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
}
};
module.exports = config;
So basically, when I go to http://localhost:9000/blog, it isn't being rendered at all. Nothing. I was using Chrome and also testing it using Safari. Also tested those two without JavaScript turned on.
And then I try to do curl http://localhost:9000/blog, and try using a requester app (like Postman) and they returned the correct html string. I also tried to do a curl using the user agent as Chrome and as Safari, it also returns the correct html.
I traced down to ghost node_modules, and the renderer is in ghost > core > server > controllers > frontend > index.js in this line res.render(view, result)
I changed the res.render to be like this
res.render(view, result, function(err, string) {
console.log("ERR", err);
console.log("String", string);
res.send(string);
})
and there is no error, it logs the current string, but it doesn't render anything on the browser.
I tried curl, postman, works, but browser doesn't work.
then I tried to send a hello world string, it works, the browser rendered it.
Then I add the string length one by one, and it turns out, any str.length < 1023 will be able to be rendered by the browser, but once it get past that, it doesn't.
And I tried in my parent Express app, it is able to send string which length is more than 1023, and if I use the ghost module as a standalone, it also able to send string more than 1023.
So something must have happened between those two, but I don't know how to debug this.
Please help

Intern functional tests: module request is missing

I've tried setting up a minimal test demonstration, but I'm stuck when I try to run tests.
What I get is:
Listening on 0.0.0.0:9000
Starting tunnel...
Error: Failed to load module request from /tmp/local-selenium-intern/request.js (parent: tests/functional)
at <node_modules/intern/node_modules/dojo/dojo.js:757:12>
at <fs.js:207:20>
at Object.oncomplete <fs.js:107:15>
What I expect is that internal modules (such as request doesn't require any explicit configuration for them to load correctly).
I have this test configuration:
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
capabilities: {
'selenium-version': '2.35.0',
'idle-timeout': 30
},
environments: [
{ browserName: 'firefox' },
{ browserName: 'chrome' }
],
maxConcurrency: 3,
useSauceConnect: false,
webdriver: {
host: 'localhost',
port: 4444
},
loader: {
// TODO: What to add here?
},
suites: [ 'tests/unit' ],
functionalSuites: [ 'tests/functional' ],
excludeInstrumentation: /^(?:tests|node_modules)\//
});
tests/functional.js contains this:
'use strict';
define([
'intern!object',
'intern/chai!assert',
'request'
], function (registerSuite, assert, request) {
registerSuite({
name: 'async demo',
'async test': function () {
var dfd = this.async(1000);
request('http://example.com/test.json').then(dfd.callback(function (data) {
assert.strictEqual(data, 'Hello world!');
}), dfd.reject.bind(dfd));
}
});
});
(An example from interns own documentation.)
The example provided is very basic and can be tested by downloading the code below followed `npm install && npm start``:
https://github.com/mzedeler/local-selenium-intern/tree/request-broken
From looking at your repository, I see you fixed the issue by using the request module from Intern's copy of Dojo. While this works, it's better to use your own copy of Dojo for your tests. Intern (the non-geezer version, at least) doesn't use standard Dojo, and makes no guarantees about the functionality therein. The current release of Dojo (1.10.0) is available through the npm repository, so it's easy to include as a project dependency.
Also, the test config in your project is a bit out of date. Specifically, the webdriver and useSauceConnect options have been replaced by tunnel and tunnelOptions. More information about the changes in Intern 2 is available in the 2.0.0 release notes.

Working with intern.js and browserstack, access the remote browser environment

I'm trying to perform a basic functional test:
define([
'intern!object',
'intern/chai!assert',
'../Request',
'require'
], function (registerSuite, assert, Request, require) {
var request,
url = 'https://github.com/theintern/intern';
registerSuite({
name: 'demo',
'submit form': function () {
return this.remote
.get(require.toUrl('./fixture.html'))
.findById('operation')
.click()
.type('hello, world')
.end()
.findById('submit')
.click()
.end()
.setFindTimeout(Infinity)
.findById('result')
.setFindTimeout(0)
.text()
.then(function (resultText) {
assert.ok(resultText.indexOf(
'"hello, world" completed successfully') > -1,
'On form submission, operation should complete successfully');
});
}
});
});
(Example from the intern.js documentation)
https://github.com/theintern/intern/wiki/Writing-Tests-with-Intern
My intern.js configuration file is as followed:
define({
proxyPort: 9000,
proxyUrl: 'http://localhost:9000/',
capabilities: {
'selenium-version': '2.41.0'
},
environments: [
{ browserName: 'chrome'}
],
maxConcurrency: 3,
tunnel: "BrowserStackTunnel",
webdriver: {
host: 'http://hub.browserstack.com/wd/hub',
username: 'XXXXX',
accessKey: 'XXXXX'
},
useSauceConnect: false,
loader: {
packages: [
{
name: "dojo",
location: 'vendor/dojo'
}
]
},
suites: [ "tests/test" ],
excludeInstrumentation: /^(?:tests|node_modules)\//
});
When I run my test, it seems that the connection is being made with browserstack, but my test keep failing:
-> ./node_modules/.bin/intern-runner config=tests/intern
Listening on 0.0.0.0:9000
Starting tunnel...
BrowserStackLocal v2.2
Ready
Initialised chrome 35.0.1916.114 on XP
Test main - index - test FAILED on chrome 35.0.1916.114 on XP:
TypeError: Cannot read property 'get' of null
at Test.registerSuite.test <tests/test.js:11:17>
at Test.run <__intern/lib/Test.js:154:19>
at <__intern/lib/Suite.js:212:13>
at signalListener <__intern/node_modules/dojo/Deferred.js:37:21>
at Promise.then.promise.then <__intern/node_modules/dojo/Deferred.js:258:5>
at <__intern/lib/Suite.js:211:46>
I assumed that the WebDriver is not loaded, how may I access the remote browser environment inside my functional test?
Only functional tests interact with a WebDriver client and have a remote property. In your config, include your test suite in the functionalSuites array, not suites.
Note that the webdriver property is no longer used, so if you want to specify your username and access key in the config file you should use tunnelOptions instead.
tunnelOptions: {
username: <username>,
accessKey: <accessKey>
}
The tunnel knows the proper hostname to use by default, so you don't need to provide that.

Resources