Currently I have Playwright tests that I am running inside Docker container both locally and in the CI. Unfortunately the tests fail on the CI with screenshot comparison error.
Upon investigation I can see that the fonts on the CI screenshots are different from the ones used to generate the expected images (also run inside docker). But this doesn't happen consistently - sometimes it happens, sometimes it doesn't. Using sharding shows that some shards pass fine and others don't inside the same job run.
Figured it out - after reviewing the trace file - it turned out that the fonts are loaded from our CDN which is on a different domain from the local one inside the Docker container where the tests are running. This results in the following CORS error and the fonts are not applied.
Access to font at 'https://mycdn.com/fonts/my-font.woff2' from origin 'http://localhost:8003' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Furthermore this issue was strangely affecting only the tests running on chromium and the ones on webkit.
After some more research I found out this Playwright issue suggesting some parameters when running tests in chromium browser which actually did the job!
So the final solution was to change the chromium configuration to:
{
name: 'chromium',
use: {
browserName: 'chromium',
bypassCSP: true,
launchOptions: {
args: ['--disable-web-security'],
},
},
},
Related
For years I've been running a Docker container on my local machine and using it as a remote Python interpreter via SSH in PyCharm. This works great (though 2022.2.1 brought a lot of new bugs that have been slowly being ironed out) for running my code! I'm now on 2022.2.3.
However, I'm having issues running unit tests. In the past (i.e. before version 2022.2.1), I could simply right click my tests directory (a direct child of my main project directory) and click Run Python tests in test... and it would all work as expected.
Now, though, when I click this, I receive an error message about "No such file or directory."
I've tried everything I can think of- I've setup my path mappings in the Python test run config to exactly match those shown in my Python run config, and have tried every version of directory and subdirectory in the mappings and working directory, but I always receive an error about either having an empty test suite (no tests found), or that the directory "must be in the project."
It seems like no matter what I do, PyCharm is trying to create a temp directory somewhere, or is trying to read from some temp directory that I never specified, because I see errors this like:
AssertionError: /tmp/pycharm_project_405/docker/tests: No such file or directory
Yet I never created, specified, or requested a temp directory of any sort, let alone one named /tmp/pycharm_project_405/; this is a mystery to me.
PyCharm with an SSH interpreter is rapidly becoming unusable for me and my team because we cannot figure out how to set this up. Can anybody please offer some guidance on what we need to do?
Thank you all so very much!
I tried:
Changing run config for Python tests to match the working directory and path mapping of Python run configs (which work)
Directly specifying the path to the tests from the container's perspective
Setting up run config templates
Specifying one directory up/down from the actual tests
Expected:
Unit tests to be found and run as they were in previous versions of PyCharm
Answer
Create a run config for testing
In the testing run config, set Target: to Custom
Set the correct remote interpreter
Set Working directory to the test folder
Set TWO path mappings: 1) Map the code directory (in my case, the parent directory of the tests folder) and 2) Map the test directory itself
Voila!!!
I have Jest tests that are running against the dockerized Neo4j Database, and sometimes they fail on CircleCI. The error message for all 25+ of them is :
thrown: "Exceeded timeout of 5000 ms for a hook.
#*******api: Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
Since they fail sometimes, like once in 25 runs, I am wondering if jest.setTimeout will solve the issue. I was able to fail them locally by setting jest.setTimeout(10), but I am not sure how to debug this even more, or whether something else could be an issue here aside from a small timeout (default 5000). I would understand if 1/25 or a few fails, or if all other suits fail, but only a single file with all tests within that file is failing. And it is always the same file, never some other file for this reason ever.
Additional information, locally, that single file runs in less than a 1000ms connected to the staging database which is huge compared to the dockerized that has only a few files at the time of running
For anyone who sees this, I was able to solve this by adding the --maxWorkers=2 flag to the test command in my CircleCI config. See here for details: https://support.circleci.com/hc/en-us/articles/360005442714-Your-test-tools-are-smart-and-that-s-a-problem-Learn-about-when-optimization-goes-wrong-
Naman's answer is perfect! I couldn't believe it but it really solved my problem. Just to be extra clear on how to do it:
I change the test script from my package.json from jest to jest --maxWorkers=2. Then I pushed and it did solve my error.
I created an application within an Angular workspace. When running
ng serve [application-name]
Picks up images and files in asset folder fine. Now I want to run the workspace with just
ng serve
I would expect through having the application lazy loaded the path would resolve but instead I get
zone.js:3243 GET http://localhost:4200/assets/terms.txt 404 (Not Found)
What is the proper setup to access assets of an application within a workspace?
EDIT After talking offline I think we've found a solution. I'll post it here and leave the below for reference even though the original answer I posted doesn't really apply to the problem.
You're trying to run multiple Angular apps and route between them via something like Firebase where you can direct different routes to different apps.
To get this to work locally for development you will need to run each Angular app separately on it's own port. I suggest you control the destination of the route in the environment files. This way when you are running locally you can point to the port the app is running on and then point to the endpoint Firebase uses in production.
Example environment.ts file in your root app
{
...,
OTHER_APP_URL: 'localhost:4201'
}
prod.environment.ts
{
...,
OTHER_APP_URL: '/otherApp'
}
Then in your component
....
import {environment} from '<path to environments file>';
#Component({
selector: 'my-component',
template: '<a [href]="otherAppUrl"></a>'
})
export class MyComponent implements OnInit {
otherAppUrl: string;
ngOnInit() {
this.otherAppUrl = environment.OTHER_APP_URL;
}
}
You will probably need to do something similar in the other apps so you can route from them to the root app or other child apps. You will probably also need to build the other apps with the --baseHref flag when you build for production so their assets are available. See here for more info from the docs: https://angular.io/cli/build
Old answer - doesn't really apply to the question
Looking at your repo I don't see the terms.txt in your root project's assets folder. I checked to see if it was in one of the other libraries in the repo but wasn't able to find it there either.
If this is an asset that is included or referenced by a component or service in one of your libraries you will need to copy that over to the library's output folder as part of your build process since that functionality isn't currently supported by the Angular CLI.
An example of a build script that might do this for you is:
ng build my-lib-with-assets --prod && cp -r projects/my-lib-with-assets/src/assets dist/my-lib-with-assets && ng build --prod
Don't forget that you need to build your libraries before you build your main project.
We are currently working on getting better code coverage for one of our JS libraries. I have the The Intern up and running, and can run tests in the browser. However, our libraries create DOM elements in some of their functions, making it so we can't run JUnit from the terminal because Node.js doesn't allow for DOM construction in tests. Is there a way we can get JUnit code coverage on the html and console output we get when we run The Intern in the browser?
I found the answer. From this link: https://theintern.github.io/intern/#local-selenium
Using ChromeDriver (Chrome-only)
If you’re just looking to have a local environment for developing functional tests, a stand-alone ChromeDriver installation works great.
1. Download the latest version of ChromeDriver
2. Set tunnel to 'NullTunnel'
3. Run chromedriver --port=4444 --url-base=wd/hub
4. Set your environments capabilities to [ { browserName: 'chrome' } ]
5. Run the test runner
Once you have that setup and running, you can run
node_modules/intern/bin/intern-runner.js config=tests/intern reporters=JUnit filename=junit.xml
This will allow the tests to run in a chrome instance, and then output the results to a report that can then be upload somewhere.
I've been attempting to get a Meteor/Cordova/Phonegap iOS app up and running. I'm following the documentation provided here: https://github.com/meteor/meteor/wiki/Meteor-Cordova-Phonegap-integration
To keep things simple I'm just testing the example leaderboard meteor project. When I follow the steps mentioned in the link above, I can run the app no problem in the iOS simulator and directly on the device via xcode using either of the following commands:
meteor run ios
or
meteor run ios-device --mobile-port 10.0.1.2:3000 -p 10.0.1.2:3000
To test a production environment, I've deployed the app directly to meteor.com
meteor deploy [my-app-name]
Following the instructions on building, I'm specifying the host and port of my remote server in the build command:
meteor build ../buildfolder -p [my-app-name].meteor.com:80
When I try running the app via the generated xcode project (in the simulator), I see nothing but a blank white screen when the app launches. There are no errors in xcode's logger, but here's what the output looks like:
16:01:41.583 [CDVTimer][file] 6.641030ms
16:01:41.607 [CDVTimer][statusbar] 23.925006ms
16:01:41.607 [CDVTimer][TotalPluginStartup] 30.839026ms
16:01:41.709 Resetting plugins due to page load.
16:01:41.739 Finished load of: (snip)
16:01:41.791 Starting the server on port 40539
16:01:41.792 Setting document root: <snip>
16:01:41.792 Started httpd on port 40539
16:01:41:792 staffutility[49019:607] HTTPServer: Started HTTP server on port 40539
16:01:41.792 addresses: {
"en1/ipv4" = "10.0.1.12";
"en1/ipv6" = "fe80::7ec3:a1ff:fea4:49c5";
"lo0/ipv4" = "127.0.0.1";
"lo0/ipv6" = "fe80::1";
"vboxnet0/ipv4" = "192.168.56.1";
}
16:01:41.794 Resetting plugins due to page load.
Note: I've also tested deploying the meteor project using Meteor Up: https://github.com/arunoda/meteor-up on my own EC2 instance, with the exact same results. The iOS app just sits there with a blank white screen. (Hitting the url via browser works fine)
Any idea what the issue might be?
Not enough reputation to comment, hence posting an answer.
Had the same issue, but the only way I could get it to work is by manually changing the host:port in Xcode. After building, open the project in xcode, go to staging > www > index.html.
In the following block, removing the port number made the app to work again.
__meteor_runtime_config__ = {"meteorRelease":"METEOR#0.9.3.1",
"ROOT_URL":"http://[my-app-name].meteor.com",
"ROOT_URL_PATH_PREFIX":"",
"DDP_DEFAULT_CONNECTION_URL":"http://[my-app-name].meteor.com",
"autoupdateVersionCordova":"426a072de258af04658e2585485c277b8aac18a3"};
I don't fully understand why, but I tried checking the port number of my app by console.logging it after deploying to meteor.com. It seems like the port number is random after deploying.
I look forward to someone throwing more light on deploying without having to include a port number.
go to your home directory (NOT your app directory)
$HOME/ rm -rf.meteor
Rerun the application
Looks like after updating to meteor 0.9.4 (which apparently includes improved Cordova/Phonegap support) my issue has been resolved.