Rotate device on an emulator in Javascript

Does driver.rotate didnt helped your purpose?

You can use below methods(java bindings)

driver.getOrientation().value(); //To find the current orientation

//To set the orientation to Landscape
driver.rotate(ScreenOrientation.LANDSCAPE);

//To set orientation to Portrait
driver.rotate(ScreenOrientation.PORTRAIT);