9

I have a Javascript project that I work on in cloud9 IDE online, and I wanted to test my code using testem npm module: npmjs.org/package/testem together with libraries like Mocha or Jasmine.

I was following this tutorial on net tuts +

I have installed the testem npm module, but when I run it using command "testem" in cloud9's terminal window testem asks me to open a new tab in "localhost:7357"

Generally to preview workspace files in cloud9 I would go to https://c9.io/username/folders.../workspace/folders.../index.html

Since I am on the cloud9 server, I wanted to know if it is possible to open this 'localhost' link from the browser, and if yes, how would I do it?

(I tried 'localhost', '127.0.0.1', '0.0.0.0' inside cloud9's IDE, but it did not work).

Maybe I can access it differently?

Like "username.cl9.io/workspace:PORT" ?

If not, maybe it is possible to provide a link and port to testem (and by any chance how would one do it ?). I know in cloud9 you can use process.env.IP and process.env.PORT to provide to different modules, but no idea on how to open such files later from the browser.

Any help will be appreciated.

Plyto
  • 741
  • 1
  • 9
  • 18

5 Answers5

5

If you are running a node process: http://workspacename.username.c9users.io will be the link to get to it.

If you want to preview a particular file in the workspace: https://c9users.io/username/workspacename/workspace/filename.html

Example:

My name is bob, and my project name is mycoolproject.

Running node service link - http://mycoolproject.bob.c9users.io

Direct file preview link - https://c9users.io/bob/mycoolproject/workspace/index.html

1j01
  • 3,714
  • 2
  • 29
  • 30
Kendell
  • 51
  • 1
5

If you run testem with the host and port variables:

testem --host $IP -p $PORT

You should be able to connect from your browser by going to the root of your external server:

http://workspace.username.c9users.io/
1j01
  • 3,714
  • 2
  • 29
  • 30
geaw35
  • 2,297
  • 3
  • 18
  • 21
1

I know this is a really late response, but I get the feeling that you simply just need the right hostname and you'll be in business. My method for getting C9's hostname is as follows:

If you open up a terminal and access the mysql command line by typing in

mysql-ctl start

followed by

mysql-ctl cli

which will take you to the MySQL command line interface, and then you can run this query:

SHOW VARIABLES WHERE Variable_name = 'hostname';

It will give you back your hostname under the column hostname which should look something like this:

yourUsername-yourProjectName-XXXXXXX

where the X's form a 7 digit number. You can use that as your hostname instead of localhost or 127.0.0.1 (which have never worked for most people and I'm not sure why people on other SO posts consistently suggest those). I have used this hostname before to sync my PHP scripts with my MySQL databases (before C9 implemented a built-in phpMyAdmin), and always had success with it.

Graham S.
  • 1,480
  • 1
  • 20
  • 28
  • o, nice. I haven't tried this myself yet, but I hope I get a chance soon. But if you had success with it, I think this is a right answer. I will mark it as so when I get a chance to test this out. Thanks a lot for the reply, I hope it will also help others with similar hostname issues. – Plyto Feb 14 '15 at 21:42
  • Your solution inadvertently solved my problem, but in Ubuntu just type `hostname` to get the c9 hostname. In my particular case I'm using `php -S (my cloud9 hostname):8080 etc` instead of localhost and that worked. I wasted a lot of time trying to get localhost to work! – PJ Brunet Jun 26 '18 at 22:18
1

on C9.io its simple for me.

Just open the file(i.e server.js or index.js or index.html) and click on preview button.

WAO you are done. :)

hope it help.

I created an application using node + express + react and then i created a simple server.js and click the preview, it open the browser.

Muhammad Asif Javed
  • 533
  • 1
  • 7
  • 19
1

sorry for that, you can't!

Available ports on a hosted Cloud9 workspace

If you're developing a server application, please note that you need to listen to 0.0.0.0 ($IP) and 8080 ($PORT). Listening to this port will enable your app to be viewable at http://-.c9users.io

You can also bind to ports 8081, and 8082, which can be accessed by http://-.c9users.io:8081 and http://-.c9users.io:8082 respectively.

Please note that 8080, 8081, and 8082 are the only available ports on a hosted Cloud9 workspace.

https://docs.c9.io/docs/run-an-application

xgqfrms
  • 10,077
  • 1
  • 69
  • 68