Getting the overall lighthouse score in an automated way - pagespeed

I'm trying to automate getting the score for a number of different pages. But the api doesn't seem to provide the overall score, like the web version does.
I've tried using the Lighthouse API v5 and v4, neither seemed to have the score, I may have missed it. I got it to work by using puppeteer on the pagespeed insights site, but that's since stopped working, and want to check I haven't missed anything before I try and fix it again

The returned JSON has a section under lighthouseResult called categories.
Within categories you will see performance and then score is a child there with the score out of 1 (so a score of 89 would be 0.89).
"lighthouseResult": {
......
"categories": {
"performance": {
"id": "performance",
"title": "Performance",
"score": 1.00, <- here is the score.
"auditRefs":
......

You must be having some issues with your setup. Try to run it via chromium, following works fine for me:
Install chromium and lighthouse:
sudo install --y chromium-browser
sudo npm install -g lighthouse
lighthouse --output-path=./Production-lighthouse-report.html URL
Script to run Lighthouse Tests on the desired URL via headless chrome:
lighthouse --chrome-flags="--headless" --output-path=./Production-lighthouse-report.html URL

Related

Publishing zip from TeamCity to Artifactory using FileSpec, does it even work?

I've tried everything I can think of to get this to work but in every attempt NO errors are returned (the logs say everything succeeded and one file was uploaded) but in artifactory, although the build info is published, nothing appears in the target repo.
I tried using powershell and the rest api to publish, but that just gave me (502 gateway error). Again, no matter what combination of values I used, always this useless error.
I have been forced to revert to using the 'legacy patterns' because this is the only thing that works AT ALL.
The pattern I am using is:
%ProjectPublishDir%\**\*.* => path/to/my/APP/%Major-Version%.%Minor-Version%/%ArtifactNamePrefix%/%ArtifactFileName%
Where all these values are parameters defined in TeamCity. This works like a charm.
However, if I add this at the end of my powershell to create the artifact:
#Write-Host "##teamcity[publishArtifacts '%ProjectPublishDir%\**\*.* => %ArtifactsDir%\%ArtifactFileName%']"
Then I replace legacy patterns with file specs for my powershell step, then I use this file spec:
{
"files": [
{
"pattern": "%ArtifactsDir%\%ArtifactFileName%",
"target": "my_repo_name/path/to/my/APP/%Major-Version%.%Minor-Version%/%ArtifactNamePrefix%/",
"props": "type=zip;status=ready"
}
]
}
The log says the artifact was generated (which I verified on the build agent is true) and that it was sent to Artifactory successfully, but when I check in artifactory, the build info is there but the artifact is missing.
Every example everywhere I can find is too simple and from the basic examples out there, what I have above should work. So what are the docs missing that I am not doing/doing incorrectly?

Cypress/Next.js E2E test with --watch option works well, but failed with --headless

Thanks for the cypress team.
I have one issue with e2e headless test on command.
When I run the test with --watch option, it passes well.
But it is failed for the --headless option.
I need to run this on CI, so it has to resolve this issues soon.
Here are commands that I run.
yarn nx run checkout-e2e:e2e --watch
yarn nx run checkout-e2e:e2e --headless
I have 3 test files totally, and the specific thing is that the first test doesn't pass after long time delay(around 60 sec) but the rest ones pass.
Here is one code file to run.
The other files are almost same.
const classname = 'buybox--buy-box-example-one-size'
const url = `?path=/story/${classname}`
describe('BuyBox Example visual regression', () => {
it('Matches the snapshot', () => {
cy.visit(url)
cy.viewport(1000, 1500)
cy.get(`#${classname}`)
cy.get('body').type('S')
cy.get('body').type('A')
cy.wait(3000)
cy.get('body').matchImageSnapshot('buyboxOneSizeDesktopExample')
cy.viewport(375, 667)
cy.get(`#${classname}`)
cy.get('body').type('S')
cy.get('body').type('A')
cy.wait(5000)
cy.get('body').matchImageSnapshot('buyboxOneSizeExample')
})
})
My Dev Env:
Windows 10
VS code
Cypress 6.0.1
Node 14.16.1
Storybook 6.2.8
Here is the error screenshot in headless mode.
https://prnt.sc/131k32j
Please reply if anyone knows its reason and solution.
Thanks.
I've tried to solve this issue and found it finally.
Go to plugin/index.js and comment this line...
// on('file:preprocessor', preprocessTypescript(config))
Fixing e2e test failed on headless mode
I am not sure why this works for me but I hope that this will be helped for everyone who has same issue.
If anyone knows the reason of this solution, comment here please.
Thanks.

Instalation of Intershop 7.9 failing on missing version for demo cartridges

I'm trying to install a demo shop of Intershop version 7.9 but i'm failing to get it working. When I run "gradlew deployServer" I'm getting an error on all dependencies of the first demo shop cartridge:
Could not resolve all dependencies for configuration ':app_sf_responsive:compile'.
Could not resolve com.intershop.business:ac_ecircle:.
Required by:
nl.test.testproject:app_sf_responsive:1.0.0-LOCAL
No version for module 'com.intershop.business:ac_ecircle' in project properties and no version declared in dependency. Consider adding a version or filter property to 'C:\projects\test7.9\projects\testproject\gradle.properties'
I have followed the complete Intershop manual Setup CI Infrastructure but there is one point I don't know exactly what to do, that's with the new versioning plugin.
It is in chapter 6.2.5, any one have an idea how to configure that?
After loads of tinkering and mails back and forth with Intershop support I found a solution.
My alterations are in section 7.2.4 of the Setup CI Infrastructure of Intershop:
https://support.intershop.com/kb/index.php/Display/279D85#Cookbook-SetupCIInfrastructure-CorporateArtifactsRecipe:SetupCIBuildforCorporateArtifacts
I Made sure the corporate distribution is unique since I have more that 1 Intershop installation. Otherwise the upload to Nexus(in my case) will still fail.
In the build.gradle of the corporate distibution folder added disableSCM = true in the scm.version section. It now looks like this:
scm {
version {
type = 'threeDigits'
increment = 'MAJOR'
patternDigits = 1
disableSCM = true
initialVersion = '2.0.0'
}
}
If this is not added I got a bad request httpstatus 400 from Nexus because it tried to upload it as a snapshot while the distribution repository is a release repository.
Another problem is the distributionURL in the project/gradle/wrapper/gradle-wrapper.properties
All Nexus repository URL's are build up with < repoBaseURL > + repositories/snapshots, but the distributionURL is missing the repositories part.
After applied those changes it worked for me.

How to delete GAVs in Nexus 3 through Nexus REST API

Is there a way to delete GAVs through a REST API in Nexus 3? From various
google searches it appears that this capability existed in Nexus 2, but not in
Nexus 3 yet. Is that true?
I tried the following with my current Nexus installation, which is OSS 3.2.1-01:
I was trying to delete GAV:
groupId = org.mycompany.myproject
artifactId = myartifact
version = 1.0.0
$ curl --request DELETE --user "USERNAME:PASSWORD" --write-out '%{http_code}\n' http://my-server:8081/service/local/repositories/my-repo/content/org.mycompany.myproject/myartifact/1.0.0
This gave me a 405.
I also looked at the release notes for 3.3 through 3.5 and nothing jumped out
that REST API support was added.
I also looked into
https://help.sonatype.com/display/NXRM3/REST+and+Integration+API. I downloaded
the nexus-book-examples and downloaded several of the Javadocs (nexus-core,
nexus-repository, nexus-common, nexus-script, nexus-commands, nexus-selector)
for version 3.2.1-01 and started to look through the code. It was not clear
where to start with a simple program to delete GAVs.
Am I correct that you cannot delete GAVs through the REST API in Nexus 3? Is
there a plan to support this in a future Nexus 3 release? Is there a way to do
what I want to do by creating a Groovy script using the code referenced by the
REST+and+Integration+API link above? Is there some sample code which will help
bootstrap me to using the above code (either 3.2.1-01, or a newer version of
Nexus).
Thanks.
You might take a look at our Beta REST API in Nexus Repository 3. Upgrade to a version greater than 3.3, preferably to 3.5 (just so you are using latest and greatest) and navigate to:
http://nexushostname:nexusport/swagger-ui/
Since the REST API is currently Beta we have yet to publish documentation or fanfare around it while we let people experiment with it and give us feedback.
You should see endpoints for deleting components and assets. You will likely want to use the component delete, so that it will clean up all associated assets.
Let me know your mileage!
According to the documentation, you can delete an ASSET (individual file) or a COMPONENT (a set of files, like jar+md5+sha1+pom.xml representing an artifact) only if you know the assetId or the componentId
https://help.sonatype.com/repomanager3/rest-and-integration-api/components-api
https://help.sonatype.com/repomanager3/rest-and-integration-api/assets-api
So you should issue a separate search call passing the GAV and finding out the componentId, then use the componentId to delete in a second call.
However I see here https://issues.sonatype.org/browse/NEXUS-11266 and here
https://issues.sonatype.org/browse/NEXUS-11881 that people can delete an asset just by specifying the entire path... I have tried with
curl -u admin:admin123 -X "DELETE" -w "%{http_code}" http://localhost:8081/repository/deployments/org/apache/commons/commons-compress/1.18/commons-compress-1.18.jar
and it gives me a HTTP 204 (no content). In my case "deployments" is a hosted repository. I have tried the same command on "central" (aproxy repo) and I get a 405.
But if I try to download the whole component (including pom, sha1 etc) with
curl -u admin:admin123 -X "DELETE" -w "%{http_code}" http://localhost:8081/repository/deployments/org/apache/commons/commons-compress/1.18/
I get a HTTP 404.
I know, it's painful and in Nexus2 it was much easier.

Why Can't PHPUnit UnitTest My Wordpress Website

I have been researching this issue for days and although many people ask this question I never found a clear and concise answer.
I am running:
PHP Unit: Version 3.7.21
WordPress: Version 3.5.1
OS: Ubuntu 11.10
MySQL: Version 5.1.69-0ubuntu0.11.10.1
PHP: Version 5.3.6-13ubuntu3.10
Long story short, I have the basic wordPress core downloaded into a directory on my computer. I have successfully downloaded and installed pear and phpunit. I tested phpunit by writing basic tests on simple php files which worked fine. My issue is when I run phpunit on a wordpress site (which I have not changed the core WP files of).
I get the error:
"PHP Fatal error: Call to a member function main() on a non-member
object in /< root_directory>/functions.php on line 779".
This error corresponds to this code-segment:
function wp( $query_vars = '' ) {
global $wp, $wp_query, $wp_the_query;
$wp->main( $query_vars ); // Line 779
if ( !isset($wp_the_query) )
$wp_the_query = $wp_query;
}
After some intense internet crawling I found many people had errors on this exact line so I know there is some general thing like an environment setting or our setup process that gave us all this error.
Some solutions I have read and tried that did not work for me:
Change the required file in your "index.php" file.
Place a require of "load.php" above the head in your "index.php" file.
Re-install WordPress
Change boot-strap and phpunit environments.
I have been a web-developer for 5 years but I have never used WordPress for one of my clients before. Once I can get this set up writing the unit tests will be easy; but I have no idea what is causing this issue. Any links to guides/tutorials or clear explanations would be greatly appreciated. Thank you for your time.
There is a WordPress test suite, which your question suggests you might have missed:
http://make.wordpress.org/core/handbook/automated-testing/
Keep in mind, with that being highlighted, that WP was not designed in such a way that it or anything related to it can or is supposed to be tested. The modus operandi has, for years, been to commit code with no tests at all. It's admittedly improving over the years, albeit at a slow pace.
Related questions:
What are the best practices of custom application Wordpress development?
WordPress Plugin: How do I avoid "tight coupling"?

Resources